3. 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
4. #include<iostream.h>
#
# is called Preprocessor directive
Preprocessing
Preprocessing is the phase of compilation before
the actual execution.
AAKASH KAUSHIK
9891983083,9289817971
5. #include<iostream.h>
#include<conio.h>
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.
AAKASH KAUSHIK
9891983083,9289817971
6. void main()
This is the main() method/ function of a C++
program. Actual execution of a program starts
from main method.
AAKASH KAUSHIK
9891983083,9289817971
7. 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
AAKASH KAUSHIK
9891983083,9289817971
8. 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
9. 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
10. clrscr();
Function defined within conio.h file
It clears the previous output screen.
AAKASH KAUSHIK
9891983083,9289817971
11. 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
12. getch();
Function defined within conio.h file
It holds the final output screen until any
key is pressed by user.
AAKASH KAUSHIK
9891983083,9289817971
13. 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
14. Escape sequences
n – New Line
t - Horizontal Tab
a - beep
// - /
/’ - ’
/” - ”
0 –Null
AAKASH KAUSHIK
9891983083,9289817971
15. 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
16. 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
17. 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