Intro to C++ programming
Page 1 of 1
Intro to C++ programming
HOW TO WRITE A PROGRAM
Writing a program is a good way to learn a programming language. Usually the first program a beginner writes a “Hello World” program. This program is simple, but it includes all the fundamentals:
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
Writing a program is a good way to learn a programming language. Usually the first program a beginner writes a “Hello World” program. This program is simple, but it includes all the fundamentals:
[You must be registered and logged in to see this link.]
Let’s analyze the codes above:
Line 1 - // my first program in C++
Two slash signs ( // ) shows that words after the signs are your comment. Programmers usually use this signs to give short explanations about the codes. In this case, it is a short introduction of the program.
Line 2 - #include< iostream >
The harsh sign ( # ) is known as a preprocessor. #include< iostream > is known as header iostream, which allows the input and output operations of the program.
Line 3 – using namespace std;
This line tells the compiler to use functions that are part of the standard library, which allows you to use "cout" functions in the program. Semicolon ( ; ) is a sign that tells the compiler that your command has come to an end.
Line 5 – int main()
Declaration of a function. This line tells the compiler there is a function called “main”, and the function will return an integer (int).
Line 6 & 11 - “ { “ and “ } ”
Beginning and ending signs of a complete function.
Line 7 - cout << “Hello World\n”;
“cout” here read as “C out”, used to display texts.” <<” is the insertion operators, used to indicate what to output. “\n” at the end of the line stands for a newline, which moves the cursor to the next line.
Line 9 - system (“PAUSE”);
A way to pause the program’s execution, it will wait for a keyboard input to continue.
Line 10 – return 0;
The program will return to the value of 0, means the program is running successfully and is returned.
Your program will look like:Line 1 - // my first program in C++
Two slash signs ( // ) shows that words after the signs are your comment. Programmers usually use this signs to give short explanations about the codes. In this case, it is a short introduction of the program.
Line 2 - #include< iostream >
The harsh sign ( # ) is known as a preprocessor. #include< iostream > is known as header iostream, which allows the input and output operations of the program.
Line 3 – using namespace std;
This line tells the compiler to use functions that are part of the standard library, which allows you to use "cout" functions in the program. Semicolon ( ; ) is a sign that tells the compiler that your command has come to an end.
Line 5 – int main()
Declaration of a function. This line tells the compiler there is a function called “main”, and the function will return an integer (int).
Line 6 & 11 - “ { “ and “ } ”
Beginning and ending signs of a complete function.
Line 7 - cout << “Hello World\n”;
“cout” here read as “C out”, used to display texts.” <<” is the insertion operators, used to indicate what to output. “\n” at the end of the line stands for a newline, which moves the cursor to the next line.
Line 9 - system (“PAUSE”);
A way to pause the program’s execution, it will wait for a keyboard input to continue.
Line 10 – return 0;
The program will return to the value of 0, means the program is running successfully and is returned.
[You must be registered and logged in to see this link.]
Rachael_C- Beginner
- Posts : 13
Points : 73541
Reputation : 0
Join date : 2014-04-27
Similar topics
» Best websites to learn Programming
» What programming language should i learn?
» C4 OBJECT – ORIENTED PROGRAMMING ( Part 1 )
» C4 OBJECT – ORIENTED PROGRAMMING ( Part 2 )
» C.2 REVISION OF FUNDAMENTAL IN PROGRAMMING (Data, Operations and Control Structures)
» What programming language should i learn?
» C4 OBJECT – ORIENTED PROGRAMMING ( Part 1 )
» C4 OBJECT – ORIENTED PROGRAMMING ( Part 2 )
» C.2 REVISION OF FUNDAMENTAL IN PROGRAMMING (Data, Operations and Control Structures)
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|