The best way to learn C++ is by practicing examples. The page contains examples on basic concepts of C++.
Write a program in C++ to add any two number.
#include<iostream.h>
void main()
{
int x,y,z;
cout<<"enter the value of x and y";
cin>>x>>y;
z=x+y;
cout<<"The addition of two number x and y is"<<z;
}
Output
enter the value x and y=5 and 6
The addition of two number x and y is=11
Write a program in C++ Divide of two number.
#include<iostream.h>
void main()
{
int x,y,z;
cout<<"enter the value of x and y";
cin>>x>>y;
z=x/y;
cout<<"The Division of two number is "<<z;
}
Output
enter the value x and y= 60 and 6
The Division of two number x and y is=10
Write a program to show Days of the week?
#include<iostream.h>
int main()
cout<<"Sunday";
cout<<"Monday";
cout<<"Tuesday";
cout<<"Wednesday";
cout<<"Thursday";
cout<<"Friday";
cout<<"Saturday";
return 0;
}
Out put
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Write a program to show Month of a year?
#include<iostrem.h>
int main()
cout<<"January";
cout<<"February";
cout<<"March";
cout<<"April";
cout<<"May";
cout<<"June";
cout<<"July";
cout<<"August";
cout<<"September";
cout<<"October";
cout<<"November";
cout<<"December";
return 0;
}
Output
January
February
March
April
May
June
July
August
September
October
November
December
Write a program to show Seasons ?
#include<iostream.h>
int main()
{
cout<<"Summer";
cout<<"Rainy";
cout<<"Autumn";
cout<<"Dew";
cout<<"Winter";
cout<<"Spring";
return 0;
}
Output
Summer
Rainy
Autumn
Dew
Winter
Spring
Write a program substract two number?
#include<iostream.h>
void main()
{
int x,y,z;
cout<<"enter the value of x and y";
cin>>x>>y;
z=x-y;
cout<<"The Subtraction of two number is "<<z;
}
Output
enter the value x and y= 10 and 6
The subtraction of two number x and y is=4
Read also: Basic of C++ Programming language, Example of C++ program..
Read also: All computer full forms , Computer course related Full forms..