Starting New Lines At the Right Time in C++
The spacing and the lines that you use in this language will be really important to the amount of success that you are going to see with it.
If you do not space things out in the proper manner, there could be some trouble with reading and understanding the code that you write, and this can add to more trouble later on.
When you decide to write out any of the codes that are needed in your program for C++, it is important that you go through and use the right line spacing to make it work.
It is not necessarily a good thing for us to go through and write out the whole code on one single line, without pauses or any breaks to it at all.
This is technically fine to do because the compiler will be able to read through it whether you do this or use another method of separating things out.
But when an actual person takes a look at it and tries to figure out what is showing up there, they will be confused because it is such a mess.
To see how this works and what we are talking about here, consider the following example:
{
cout << Try This;>> endl; << Today I ate Pizza and did Math;>> endl; <<6=(7-1);>> endl; << That is what I learned today;>> endl;
return 0
}
This line is technically right.
You would be able to put it into the compiler, and it will read through all of this just fine.
However, it is really hard to read through this, especially if you are brand-new to the idea of coding.
This particular one would not be that bad, but if you get to a longer code, it would be almost impossible to figure out what is going on or even to catch mistakes that you may have made.
There is another way that you can write out the code.
It will mean the exact same thing, and the compiler will read it the same way, but it is better because other programmers, as well as yourself, will be able to read through the code a little bit better. a better way to write out the code includes the following:
{
cout << Try This;>> endl;
<<Today I ate Pizza and did Math;>> endl;
<<6=(7-1);>> endl;
<< That is what I learned today;>> endl;
return 0
}
As you can see, this is much easier to read through.
It says the exact same thing as the first one, but it looks a lot better and it easier to read.
Good coding practices will ask you to write like on the second example, rather than the first one, although your compiler will accept both.