How to write first Program in C++?

How to write first Program in C++?


First Program in C++

It is very easy to write first program in C++ using "Hello World" example program. You will learn first C++ program with example and detailed description. See following example program that print a single line. It demonstrates all three part of C++ structure including Preprocessor Directives, Main Function and C++ Statements.



Program Explanation

Line 1 : There is a preprocessor at this line that is including a header file called iostream.h that contains all declarations and definitions of all input and output functions (cin, cout).
Line 2 : This line contain second preprocessor that include another header file called conio.h that contain console input/ output library function (clrscr()).
Line 3 : It is a blank line
Line 4 : It contain main function. Void at the start of main represent that main function returns nothing and void in small brackets after main represents that main function cannot accept any parameters / arguments.
Line 5 : It contains opening curly bracket of main function.
Line 6 : It contains a cout (console output) statement that prints “Welcome to C++”.
Line 7 : It is closing curly bracket that represents the ending of main function.

Post a Comment

Previous Post Next Post