Header Responsive Ads

Download and install Dev C++

download and install dev c++

Dev C++ download (Devshed C++) from https://sourceforge.net/projects/orwelldevcpp/. You can fee download dev c++ and install (You may use Dev C++ online) 

Create C++ file

Open Dev C++ and create a new file

create cpp file

Write a first C++ program

first cpp program

Save the file by pressing Ctrl + S OR by File => Save and type the file name. Now compile the program and run. You can perform compile and run separately. However, I suggest to compile and run together by following three ways:- 
  • Press F11 from the keyboard
  • Go to Execute => Compile & Run
  • Click on Compile & Run icon

compile c++
Output
first cpp program output

Let us explain the program line by line

Line 1:

#include is C++ header file from C++ library. It provides us cout word to display output (and also cin to get input). C++ contains several header files and we can use them. Iostream C++ header file is used to get input from the user and display output to the screen 

Line 2:

using namespace std c++ let us use cin and cout word in a simple direct way. Without writing it, we have to write std:: with all cout’s and cin’s in the program like std::cout<<”Hello World!”; 

Line 3:

int main() This is the main function of the program where control starts execution. 

Line 4:

Curly brackets {} is the body of this function. Program starts its execution from the body of the main function. Don't worry if you don't understand how #include , using namespace std and int main() works. It will be covered in coming tutorials. 

Line 5,6:

{ cout << "Hello World! "; } 

{ is open curly bracket to start body of main function. cout c++ used together with the insertion operator (<<) to output/print text on the screen. In our example, it will output "Hello World". 

} is the close curly bracket to close the main function. 

Note:

All statements of C++ end with a semicolon ; 

Remember:

You can insert empty lines (white spaces) between code lines because C++ compiler ignores these lines. cin strings is used to get user input, will be covered in the next lesson.


Post a Comment

Previous Post Next Post

In Article Ads 1 Before Post

In Article Ads 2 After Post