Inevitably, whoever you are writing code for will dictate how you form a code.
So sometimes it makes sense.
For example, if you use some form of preprocessing to extract code and definitions to create a documentation
for the code.
In many cases, this style that is imposed on you is the personal preference of someone else of you
or you.
So there are two broad formatting styles in C++, R and all men.
So in general can are places the opening phrase of a code block on the same line of the list.
Last statement.
As you can see here, same line of statement and same line of statement as you can see here.
But.
Here.
As you can see, this is the typical typically used in UNIX operating systems, but there is an all
months stale, all meant stale style is typically used in Windows Microsoft systems.
So they are all style named after the developer.
Eric Amen.
So places the opening brace on a new line.
As you can see, it is the new one.
So the nested examples look nested example looks as follows.
Here.
This is the.
Allman Style.
And actually, we will miss the LS statement here.
LS And the test is false.
And here's the second test.
Second test is false.
And this is the almost all man style.
So remember, remember that your code is unlikely to present that on a paper.
So the fact that an R is more compact will save on trees.
If you have the choice, you should choose the style that is the most readable that the decision of.
So for it's my decision is the is that keener is more readable I think.
But if you choose all, it's completely okay.
So you can choose however you want.
Just don't mix.
Two is to code styles because the code will become the unreadable here.
For example, if you mix the Key and R and Allman, it's not okay, but it's a syntax and the compiler,
the compiler with no problem.
So if you have multiple nested blocks, the intense can give an idea of which block the code resides.
And however, comments can help too here.
So in particular, if a code black has a large amount of code, it's often helpful to comment the reason
for the code block So for example, if an if statement is the it is helpful to put the result of the
test in the code.
BLOCK So you know what the variable values are in that block.
So it's also useful to put a comment on the closing brace of a test here.
So.
So let's let's write an example program here.
Example just an.
Example.
One year.
So let's create an if.
What's here?
If X.
Let's create.
First, let's create the integer.
Integer x equals one.
If X is is greater than zero, you will learn about all of this if and ll statements in next lectures.
This is just an example.
So just keep in mind.
And here then X greater than this.
And here we will add the lots of code quotes here.
And then lastly, if.
If.
It's less than zero.
And let's add our statement to.
Else.
Let's hear.
Then as X.
Is greater than or equal to zero.
If so, if it is not less than zero, then X is greater than or less than zero.
So we just wrote it as common so it doesn't comment.
So it's for easy to understand in the next C++ programmers.
So here lots of codes again.
Again, lots of codes.
And then.
If.
Here X is less than zero.
Just mentioning that this ls is the if statement.
Else.
So there's is nothing else here.
If you put this as a comment on a closing brace, it means that you have a search term that you can
use to find the test that resulted in the code.
BLOCK.
So the preceding lines make this comment irrelevant.
But when you have the code blocks with the many tens of lines of code and with many levels of nesting,
commenting like this can be very helpful.
So for example, oh, I'm searching for my x less than zero statement.
Where is the statement?
You just press the control plus F here of some control plus F here and then x less than zero.
As you can see here, our idea of or you can use just the text processing applications as well.
If you just use this commenting type, you will get the.
Your desired search result.
In next lecture, we're going to learn about the writing statements.
So I'm weighting you in next lecture.