Introduction to C++ :
C++ programstructure :
To write C++ program, we have to follow step by step code-based statement’s structure called program structure. It has following structure of C++ program.
t tructure : To write C++ program, we have to follow step
by step code-based statement’s structure called program structure.
It has following structure of C++ program.
Basic Program structure:
#include <iostream.h>
void main()
{
// program
}
#include<iostream.h>
void main()
{
// main program
}
1. In this first line include Header file also called library of C++ like iostream.h,
conio.h, stdio.h,math.h etc.
2. The function named main () is a special function in all C++ programs; it is the
function called when the program is run. The execution of all C++ programs
begins with the main() function. In this void is keyword used as data type that
means it won’t t return value and main () is function that conveys information to
compiler that actual program is going to start from this place.
3. Curly bracket opening and closing (both brackets must match) have code area is
used to write the program. Every program must consist only one main().
conio.h, stdio.h,math.h etc.
2. The function named main () is a special function in all C++ programs; it is the
function called when the program is run. The execution of all C++ programs
begins with the main() function. In this void is keyword used as data type that
means it won’t t return value and main () is function that conveys information to
compiler that actual program is going to start from this place.
3. Curly bracket opening and closing (both brackets must match) have code area is
used to write the program. Every program must consist only one main().
Introduction to C++ programstructure : To write C++ program, we have to follow step
by step code-based statement’s structure called program structure.
It has following structure of C++ program.
Basic Program structure(POP)
#include<iostream.h>
void main()
{
// main program
}
In case of C++, it uses streams to perform input and output operations in standard
input output devices (keyboard and monitor). A stream is an object which can either
insert or extract the character from it.
1) cin (console-input) is Input statement used to enter the value from user by the
keyboard. It is predefined object of istream class that follows redirection/
extractionoperator>>to read the input value from the console. This statement
cannot be use to print information.
EX. int num; cin>>num;
2) cout (console-output) is output statement used to show the output. cout is
predefined object of ostream class that follows insertion operator<< to display
information.
int num;
cout<<”Enter the value of num : ”;
cin>>num;
cout<<” Entered num value is : “<<num; //cascade or chain of statement
Note : Here statement enclosed in “ “ is information that will print as it is and num is
variable that has some value, so it won’t enclosed in “ “.
First program
#include <iostream.h>
void main()
{
cout<< “ Hello this is my first program in C++ \n “;
cout<< “ Welcome to my first program “;
}

0 Comments