BASIC STRUCTURE OF A C++ PROGRAM
HEADER FILES
COUT
CLRSCR
GETCH
COMPILE A PROGRAM
EXECUTE A PROGRAM
Size: 124.94 KB
Language: en
Added: Sep 15, 2014
Slides: 18 pages
Slide Content
C++ Language By:-AAKASH KAUSHIK #9289817971, 98919893083 [email protected]
UNIT -2 BASIC STRUCTURE OF A C++ PROGRAM
BASIC STRUCTURE OF A C++ PROGRAM #include< iostream.h > #include< conio.h > void main() { clrscr (); Program code will be written here getch (); } AAKASH KAUSHIK 9891983083,9289817971
# # is called Preprocessor directive Preprocessing Preprocessing is the phase of compilation before the actual execution. # include< iostream.h > AAKASH KAUSHIK 9891983083,9289817971
These are the header file inclusion statement Header Files Header files are the predefined files in the C++ library using which we create new program. #include< iostream.h > #include< conio.h > AAKASH KAUSHIK 9891983083,9289817971
This is the main() method/ function of a C++ program. Actual execution of a program starts from main method. void main() AAKASH KAUSHIK 9891983083,9289817971
First C++ Program #include< iostream.h > #include< conio.h > void main() { clrscr (); cout <<“My First C++ Program”; getch (); } TO COMPILE- Alt+F9 TO EXECUTE-Ctrl+F9 VIEW OUTPUT AAKASH KAUSHIK 9891983083,9289817971
iostream.h Iostream stands for Input Output Stream It contains functions related to input and output. For ex.- cout,cin etc. AAKASH KAUSHIK 9891983083,9289817971
conio.h conio stands for Console Input Output . It contains functions related to Console screen input and output. The output screen of C++ is called Console Screen. AAKASH KAUSHIK 9891983083,9289817971
clrscr (); Function defined within conio.h file It clears the previous output screen. AAKASH KAUSHIK 9891983083,9289817971
cout <<“ text to be display”; Defined within iostream.h The text written within double quotes(“ ”) will got displayed on the output screen as it is. AAKASH KAUSHIK 9891983083,9289817971
getch (); Function defined within conio.h file It holds the final output screen until any key is pressed by user. AAKASH KAUSHIK 9891983083,9289817971
RULES OF C++ LANGUAGE Every program should have main() Every statement should be end with semicolon(;) This Language is case sensitive All the letter should be in lowercase. AAKASH KAUSHIK 9891983083,9289817971
Comments in a C++ Program Comments are used to increase understandability and readability of a program. These comments will be ignored by the compiler at the time of compilation/execution. i.e , comments are part of a program but not the part of compiled/executed code. AAKASH KAUSHIK 9891983083,9289817971
Type of Comments SINGLE LINE COMMENT Starts with // and treats all the contents following // as comments within that line MULTIPLE LINE COMMENT Starts with /* and ends with */ and all the contents in between will be treated as comments AAKASH KAUSHIK 9891983083,9289817971
COMMENTS USAGE EXAMPLE /* TITLE :- MY FIRST C++ PROGRAM CREATED BY :- XYZ */ #include< iostream.h > #include< conio.h > void main() { clrscr (); // to clear the output screen cout <<“My First C++ Program”; getch (); //to pause the final output } AAKASH KAUSHIK 9891983083,9289817971