0% found this document useful (0 votes)
4 views2 pages

C++ Area and Interest Calculations

The document contains C++ code snippets for calculating the area of a square, area of a triangle, simple interest, and the area and perimeter of a rectangle. Each code snippet prompts the user for necessary inputs and displays the calculated results. The use of standard input/output libraries and basic arithmetic operations is demonstrated in each example.

Uploaded by

sudipdipu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

C++ Area and Interest Calculations

The document contains C++ code snippets for calculating the area of a square, area of a triangle, simple interest, and the area and perimeter of a rectangle. Each code snippet prompts the user for necessary inputs and displays the calculated results. The use of standard input/output libraries and basic arithmetic operations is demonstrated in each example.

Uploaded by

sudipdipu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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();
}

You might also like