Basic C++ Programming Language Example..

 The best way to learn C++ is by practicing examples. The page contains examples on basic concepts of C++. 


c++ program



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

Write a program to multiple two number?

#include<iostream.h>
int main()
{
int a,b;
cout<<" Enter a number";
cin>>a;
cout<<"Enter a number";
cin>>b;
cout<<''Multiplication of two number is"<<a*b;
return 0;
}

Output
Enter a number 9
Enter a number 8
Multiplication of two number is 72

Write a program to calculate area of a Rectangle ?

#include<iostream.h>
int main()
{
const int length=10;
const int width=5;
int area;
area=length*width;
cout<<area;
return 0;
}

Output

area of rectangle is 50


Read also: Basic of C++ Programming  language, Example of C++ program..

Read also: All computer full forms , Computer course related Full forms..


Post a Comment

Previous Post Next Post