c++ programming Unit 2 basic structure of a c++ program

aakashkumar507679 13,448 views 18 slides Sep 15, 2014
Slide 1
Slide 1 of 18
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18

About This Presentation

BASIC STRUCTURE OF A C++ PROGRAM
HEADER FILES
COUT
CLRSCR
GETCH
COMPILE A PROGRAM
EXECUTE A PROGRAM


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

Escape sequences \n – New Line \t - Horizontal Tab \a - beep // - / /’ - ’ /” - ” \0 –Null 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

THANK YOU AAKASH KAUSHIK 9891983083,9289817971
Tags