1.
In C++, calculate the area of a square
#include<iostream.h>
#include<conio.h>
void main()
{
float len, area;
cout<<"Enter the Length of Square: ";
cin>>len;
area = len*len;
cout<<"\nArea = "<<area;
cout<<endl;
getch();
}
2. In C++, find the area of a triangle based on its base and height
#include<iostream.h>
#include<conio.h>
void main()
{
float b, h, area;
cout<<"Enter Base length of Triangle: ";
cin>>b;
cout<<"Enter Height length of Triangle: ";
cin>>h;
area = 0.5*b*h;
cout<<"\nArea = "<<area;
cout<<endl;
getch();
}
3. Calculate Simple Interest in C++
#include<iostream.h>
#include<conio.h>
void main()
{
float p, r, t, si;
cout<<"Enter Principle Amount: ";
cin>>p;
cout<<"Enter Rate of Interest: ";
cin>>r;
cout<<"Enter Time Period: ";
cin>>t;
si = (p*r*t)/100;
cout<<"\nSimple Interest Amount: "<<si;
cout<<endl;
getch();
}
4. In C++,Find the Area and Perimeter of a Rectangle
#include<iostream.h>
#include<conio.h>
void main()
{
int width, lngth, area, peri;
cout << " Input the length of the rectangle : ";
cin >> lngth;
cout << " Input the width of the rectangle : ";
cin >> width;
area = (lngth * width);
peri = 2 * (lngth + width);
cout << " The area of the rectangle is : "<< area << endl;
cout << " The perimeter of the rectangle is : "<< peri << endl;
getch();
}