C++ Lesson 5 – Get ready for the first program – Part 2

If you have not studied our previous lessons yet, please access our lessons using these URLs.

C++ full tutorial | How to start C++ | Part 001
C++ Lesson 2: Setting the PROGRAMMING Background for WINDOWS
C++ Lesson 3 – Setting the background PROGRAMMING for LINUX
C++ Lesson 4 – Get ready for the first program

We identify the basic format of C++ programming.

We probably got to the basics of the C++ program. The last step is to understand the structure of the source code.

[include statements]
using namespace std;
int main()

{
[your code here];
}

What if you miss a part?

If you can’t include the “include declaration” or “using the std namespace”, your program will fail to compile. The program is not compiled correctly, which means that something the compiler cannot recognize is included in the code. It could be a syntax error. Or you can forget to include the header file. We can see at least one or more errors in any compiler error. An example of this failure can be found on the street.

error: ‘cout’ was not declared in this scope

Comment in your programming.

If you learn to program, you need to know something. Here’s how to add an idea or description into a code. It is very important for those unfamiliar with programming. In this way, he can immediately explain the functionality of a particular section or line of our code. These comments are considered a good use of programming. So let’s see how.

If you enter a section as a comment, the compiler skips that part of the code when it is executed. The // marker indicates that a part of the compiler has a comment. Due to the use of this sign, the compiler recognizes that the whole line of that sign is the same comment. But we can only use it for a one-line comment. If we want to publish a section of a line as a comment, we use these two points. / * Comment here * / we must insert our comment between these two.

For example:

// This line is just a comment.
This line is not a comment. (I.e. this is part of the code)

/ * The first line e
The second line contains both comments
* /

We can use it for something else. That is, if we don’t want to see the result of a statement, we can make a comment. For example, if we want to see the result of a cout statement, we can turn that part into a comment.

#include <iostream>
using namespace std;
int main ()

{
// cout << “hi, i’m SecDevil.com admin!\n”;
}

If there is something wrong with our code, we can use this method.

We learn to think like a programmer.

A programmer is someone who always takes care of computers. So to be a good programmer, we need to understand computers. Computers are really just a tool to do what we say. You can’t do anything the computer can’t do. If we want to get something from our computer, we have to explain it in detail, how to do it. It’s a little frustrating but it’s the truth.

But luckily we can do it when you’re programming, just give the computer a name to describe how it works. So when we do it again, it is not necessary to enter all these details. You can understand this better while we work with the functions. Well, we’ve just finished our first program. And beyond that, we talked a little more. I think many of you have an idea of ​​C++ programming right now. I’d like to hear from you. Is this how I go for this lesson? Do you understand well Are there any shortcomings? Well, the next lesson is about using variables. We will meet again with that lesson.

Leave a Reply

Your email address will not be published. Required fields are marked *