Thursday, January 2, 2014

C++ Program to Print Something on the Screen as You Want [C++ 01]

This is the first C++ Program for the beginners. This program will print the text that you will provide into the line std::cout << "This is my first C++ Program!"; You may replace This is my first C++ Program! with the text you want to print on the screen.

#include <iostream>
int main()
{
  std::cout << "This is my first C++ Program!";
}

Output of the above C++ Program: This is my first C++ Program!


Line 01: #include <iostream>
This line tells the processor to include a header section named iostream. The compiler execute this line before all other. Because all the instruction it needs are included iostream header file.

Line 02: int main()
This is the main function as like as main (), we use in C Program. The main program start from here.

Line 03: { [Opening Brace]
This is the opening brace we used at the third line in the program. This opening brace indicates the beginning of the main function. Actually the main program written by the programmer start from here.

Line 04: std::cout << "This is my first C++ Program!";
This id the fourth line we have used into the above program to tell the processor to print This is my first C++ Program! on the screen. You can replace this line (This is my first C++ Program!) with anything you like to print on the screen.

Line 05: } [Closing Brace]
The closing brace at the fifth line we have used to indicate the ending of the program.

Read the writings on How to run a C++ Program in CodeBlocks if you fail to run.

No comments:

Post a Comment