Basic Format of C++ Program
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
.............
.............
getch();
}
C++ Program to Print Name and Address
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"AIPS ACADEMY";
cout<<"\n Abadganj";
getch();
}
Output
AIPS ACADEMY
Abadganj
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"AIPS ACADEMY\n";
cout<<"Abadganj";
getch();
}
Output
AIPS ACADEMY
Abadganj
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"AIPS ACADEMY"<<endl;
cout<<"Abadganj";
getch();
}
Output
AIPS ACADEMY
Abadganj
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"AIPS ACADEMY";
cout<<endl<<"Abadganj";
getch();
}
Output
AIPS ACADEMY
Abadganj
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
cout<<"AIPS ACADEMY \nAbadganj";
getch();
}
Output
AIPS ACADEMY
Abadganj
OR
/* Q. write a program to print your Name.
and Address. */
#include<iostream.h>
#include<conio.h>
void main() // indicates Starting of program
{
clrscr(); //to clear the screen
cout<<"AIPS ACADEMY";
cout<<"\n Abadganj";
getch();
}
Output
AIPS ACADEMY
Abadganj
C++ Program #Find sum of two numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
a=10;
b=5;
c=a+b;
cout<<"Sum="<<c;
getch();
}
Output
Sum=15
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
a=10;
b=5;
cout<<"Sum="<<(a+b);
getch();
}
Output
Sum=15
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float x,y,z;
x=10;
y=5;
z=x+y;
cout<<"Sum="<<z;
getch();
}
Output
Sum=15
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float n1,n2,n3;
n1=10;
n2=5;
n3=n1+n2;
cout<<"Sum="<<n3;
getch();
}
Output
Sum=15
C++ Program #Find subtraction of two numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=10;
b=5;
c=a-b;
cout<<"Sub="<<c;
getch();
}
Output
Sub=5
C++ Program #Find Multiplication of two numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
a=10;
b=5;
c=a*b;
cout<<"Multiplication="<<c;
getch();
}
Output
Multiplication=50
C++ Program #Find division of two numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
a=5;
b=2;
c=a/b;
cout<<"Division="<<c;
getch();
}
Output
Division=2.5
C++ Program #Find Integer division of two numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=10;
b=3;
c=a/b;
cout<<"Integer Division="<<c;
getch();
}
Output
Integer Division=3
C++ Program #Find Modulo division of two numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
a=10;
b=3;
c=a%b;
cout<<"Modulo Division="<<c;
getch();
}
Output
Modulo Division=1
Q) What will be result of the following expression s when A=5, B=10 and C=15 ?
a) D=A+ C% B
b) D= A+B*5– C
What will be result of the following expression s when A=5, B=10 and C=15 ?
a) D=B+ C% A
b) D= B – C / A
What will be result of the following expression s when A=6, B=7 and C=8 ?
a) D=A + C% B
b) D= A + B *5 – C
What will be result of the following expression s when A=4, B=6 and C=8 ?
a) D=++A + C% ++B
b) D= A + ++B *2 – C
C++ Program #Find sum of two numbers. (Compile Time)
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
a=10;
b=5;
c=a+b;
cout<<"Sum="<<c;
getch();
}
Output
Sum=15
OR C++ Program #Find sum of two numbers. ( Run time )
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
cout<<"Enter value of a=";
cin>>a;
cout<<"Enter value of b=";
cin>>b;
c=a+b;
cout<<"Sum="<<c;
getch();
}
Output:
Enter value of a =5
Enter value of b =7
Sum=12
OR Run time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
cout<<"Enter value of a and b=";
cin>>a>>b;
c=a+b;
cout<<"Sum="<<c;
getch();
}
Output:
Enter value of a and b=5
7
Sum=12
C++ Program #Find sum of three numbers.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,d;
a=5;
b=7;
c=9;
d=a+b+c;
cout<<"Sum="<<d;
getch();
}
Output:
Sum=21
OR Run time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,d;
cout<<"Enter value of a,b and c=";
cin>>a>>b>>c;
d=a+b+c;
cout<<"Sum="<<d;
getch();
}
Output:
Enter value of a ,b and c=5
7
9
Sum=21
C++ Program #Find Area of Rectangle
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float l,b,a;
l=10;
b=5;
a=l*b;
cout<<"Area of Rectangle="<<a;
getch();
}
Output
Area of Rectangle=50
Run time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float l,b,a;
cout<<"Enter Length and Breadth=";
cin>>l>>b;
a=l*b;
cout<<"Area of Rectangle="<<a;
getch();
}
Output
Enter Length and Breadth=10
5
Area of Rectangle=50
C++ Program #Find Perimeter of Rectangle
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float l,b,p;
l=10;
b=5;
p=2*(l+b);
cout<<"Perimeter of Rectangle="<<p;
getch();
}
Output
Perimeter of Rectangle=30
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float l,b,p;
cout<<"Enter Length and Breadth=";
cin>>l>>b;
p=2*(l+b);
cout<<"Perimeter of Rectangle="<<p;
getch();
}
Output
Enter Length and Breadth=10
5
Perimeter of Rectangle=30
C++ Program #Find Area and Perimeter of Rectangle
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float l,b,a,p;
l=10;
b=5;
a=l*b;
p=2*(l+b);
cout<<"Area of Rectangle="<<a;
cout<<"\nPerimeter of Rectangle="<<p;
getch();
}
Output
Area of Rectangle=50
Perimeter of Rectangle=30
Run Time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float l,b,a,p;
cout<<"Enter Length and Breadth=";
cin>>l>>b;
a=l*b;
p=2*(l+b);
cout<<"Area of Rectangle="<<a;
cout<<"\nPerimeter of Rectangle="<<p;
getch();
}
Output
Enter Length and Breadth=10
5
Area of Rectangle=50
Perimeter of Rectangle=30
C++ Program #Find Area of Square
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float s,a;
s=10;
a=s*s;
cout<<"Area of square="<<a;
getch();
}
Output
Area of square=100
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float s,a;
cout<<"Enter Side=";
cin>>s;
a=s*s;
cout<<"Area of square="<<a;
getch();
}
Output
Enter side=10
Area of square=100
C++ Program #Find Perimeter of Square
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float s,p;
s=10;
p=4*s;
cout<<"Perimeter of Square="<<p;
getch();
}
Output
Perimeter of Square=40
Run Time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float s,p;
cout<<"Enter Side=";
cin>>s;
p=4*s;
cout<<"Perimeter of Square="<<p;
getch();
}
Output
Enter side=10
Perimeter of Square=40
C++ Program #Find Area and Perimeter of Square
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float s,a,p;
s=10;
a=s*s;
p=4*s;
cout<<"Area of Square="<<a;
cout<<"\nPerimeter of Square="<<p;
getch();
}
Output
Area of Square=100
Perimeter of Square=40
Run Time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float s,a,p;
cout<<"Enter Side=";
cin>>s;
a=s*s;
p=4*s;
cout<<"Area of Square="<<a;
cout<<"\nPerimeter of Square="<<p;
getch();
}
Output
Enter side=10
Area of Square=100
Perimeter of Square=40
Circle
+ Program #Find Area of Circle
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float r,a;
r=5;
a=3.14*r*r;
cout<<"Area of circle="<<a;
getch();
}
Output
Area of circle=78.5
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float r,a;
cout<<"Enter radius=";
cin>>r;
a=3.14*r*r;
cout<<"Area of circle="<<a;
getch();
}
Output
Enter radius=5
Area of circle=78.5
C++ Program #Find Perimeter of Circle
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float r,p;
r=5;
p=2*3.14*r;
cout<<"Perimeter of circle="<<p;
getch();
}
Output
Perimeter of circle=31.4
Run Time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float r,p;
cout<<"Enter radius=";
cin>>r;
p=2*3.14*r;
cout<<"Perimeter of circle="<<p;
getch();
}
Output
Enter radius=5
Perimeter of circle=31.4
C++ Program #Find Area and Perimeter of circle
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float r,a,p;
r=5;
a=3.14*r*r;
p=2*3.14*r;
cout<<"Area of circle="<<a;
cout<<"\nPerimeter of circle="<<p;
getch();
}
Output
Area of circle=78.5
Perimeter of circle=31.4
Run Time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float r,a,p;
cout<<"Enter radius=";
cin>>r;
a=3.14*r*r;
p=2*3.14*r;
cout<<"Area of circle="<<a;
cout<<"\nPerimeter of circle="<<p;
getch();
}
Output
Enter radius=5
Area of circle=78.5
Perimeter of circle=31.4
C++ Program #Find Simple interest
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float p,r,t,s;
p=1000;
r=5;
t=3;
s=(p*r*t)/100;
cout<<"Simple interest="<<s;
getch();
}
Output:
Simple interest=150
Run time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float p,r,t,s;
cout<<"Enter value of P, R and T=";
cin>>p>>r>>t;
s=(p*r*t)/100;
cout<<"Simple interest="<<s;
getch();
}
Output
Enter value of P, R and T=1000
5
3
Simple interest=150
Write a program in C++ to find the square and cube of entered integer number. (2017)
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float n,s,c;
n=5;
s=n*n;
c=n*n*n;
cout<<"Square="<<s;
cout<<"\nCube="<<c;
getch();
}
Output
Square=25
Cube=125
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float n;
n=5;
cout<<"Square="<<(n*n);
cout<<"\nCube="<<(n*n*n);
getch();
}
Output
Square=25
Cube=125
Run Time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float n,s,c;
cout<<"Enter any number=";
cin>>n;
s=n*n;
c=n*n*n;
cout<<"Square="<<s;
cout<<"\nCube="<<c;
getch();
}
Output
Enter any number=5
Square=25
Cube=125
Write a program to enter any two numbers and print the sum, difference and product in separate
line with appropriate message. (2017)
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,d,e;
a=5;
b=3;
c=a+b;
d=a-b;
e=a*b;
cout<<"Sum="<<c;
cout<<"\nDifference="<<d;
cout<<"\nProduct="<<e;
getch();
}
Output
Sum=8
Difference=2
Product=15
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
a=5;
b=3;
cout<<"Sum="<<(a+b);
cout<<"\nDifference="<<(a-b);
cout<<"\nProduct="<<(a*b);
getch();
}
Output
Sum=8
Difference=2
Product=15
OR Run Time
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,d,e;
cout<<"Enter value of a and b=";
cin>>a>>b;
c=a+b;
d=a-b;
e=a*b;
cout<<"Sum="<<c;
cout<<"\nDifference="<<d;
cout<<"\nProduct="<<e;
getch();
}
Output
Enter value of a and b=5
3
Sum=8
Difference=2
Product=15
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
cout<<"Enter value of a and b=";
cin>>a>>b;
cout<<"Sum="<<(a+b);
cout<<"\nDifference="<<(a-b);
cout<<"\nProduct="<<(a*b);
getch();
}
Output
Enter value of a and b=5
3
Sum=8
Difference=2
Product=15
Write a Program to find out the sum and average of any four entered numbers. (2015)
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,d,e,f;
a=10;
b=20;
c=30;
d=40;
e=a+b+c+d;
f=e/4;
cout<<"Sum="<<e;
cout<<"\nAverage="<<f;
getch();
}
Output
Sum=100
Average=25
OR
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,d,e,f;
cout<<"Enter value of a,b,c and d=";
cin>>a>>b>>c>>d;
e=a+b+c+d;
f=e/4;
cout<<"Sum="<<e;
cout<<"\nAverage="<<f;
getch();
}
Enter value of a,b,c and d=10
20
30
40
Sum=100
Average=25
Write a program in C++ to convert the entered temperature in Celsius into Fahrenheit(using
formula: C=5/9*(F-32)).
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float c,f;
cout<<"Enter temperature in Celsius=";
cin>>c;
f=((9*c)+160)/5;
cout<<"Fahrenheit="<<f;
getch();
}
Output
Enter temperature in Celsius=37
Fahrenheit=98.6
Write a program to find Square Root of a number.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float n,r;
cout<<"Enter any number=";
cin>>n;
r=sqrt(n);
cout<<"Square Root="<<r;
getch();
}
Output
Enter any number=25
Square Root=5
Write a program to find Power value.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float b,p,r;
cout<<"Enter base and power=";
cin>>b>>p;
r=pow(b,p);
cout<<"Power Value="<<r;
getch();
}
Output
Enter base and power=5
3
Power value=125
Write a program to find Compound interest.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float p,r,t,x,y,z;
cout<<"Enter principal,rate and time=";
cin>>p>>r>>t;
x=1+r/100;
y=pow(x,t);
z=y*p-p;
cout<<"Compound interest="<<z;
getch();
}
Enter principal,rate and time=1000
5
3
Compound interest=1157.625
C++ Program to Find area Triangle
C++ Program to Find area Triangle using Hero’s Formula
To be continued… Please check daily for more updates..
Nice
Acha h
Very good
Nice
Your Hard work is shining here Sir
Keep it up this will surely help the people like me
I am very gratefull to you sir for this help i blindely follow your blogs and it is really develop our knowladge of programming skills
Thank you
❣️🙏