Friday, 6 February 2015

Basic Structure Of C++ Program.

                                                               A c++ program is a collection of functions. the program also contains the list of library files included for adding the contents to the program. Here we will study c++ program concept through some example,
                                     

#include<iostream.h>    // header file
#include<conio.h>        //header file
void main()                   // main part
{


clrscr();  //function to clear the screen.

cout<<"Welcome to the world of c++ programming";


}

 OUTPUT OF THIS PROGRAM IS




// the slash represent a comment and it may start anywhere. These are ignored by the compiler.


The first line of program #include<iostream.h> is necessary. This is a header file. This is a library file that is used for the keyword cout and #include<conio.h> in 2nd line used for clrscr();. # is a preprocessor directive. It tell the compiler that what is the function of the header file.

The third line of the program shows Every c++ program must have a function main() because compiler always start execution with main(). there is a return type that is void which is very important. this mean main return nothing. The parentheses are also required.

The fourth and seven lines of the program shows the braces { and }. these braces enclosed the body of the main i.e the body of main part. The opening brace ({) shows the beginning of main part and closing brace(}) shows the end of the main part.

The fifth line of program contain clrscr() that is use to clear the screen. 

The sixth line contain the statement i.e cout<<"welcome to the world of c++ program"; basically displays the string on the output screen. cout pronounced as a "see out". There above is a output screen on which you can see that there is a string that is displayed with the help of cout statement. 







  



                                                                                                                                                                                        

No comments:

Post a Comment