Music ku

Monday, February 28, 2011

Exercises no 6

Program that will calculate the area of rectangular, triangle and circle.

#include <iostream.h>
main()
{
double area_rect , area_triangle, area_circle, base , height, width, radius;
const double π=3.14; 
cout<<"Calculate area of rectangular.";
cout<<"Enter height=";
cin>>height;
cout<<"Enter width";
cin>>width;
area_rect=height * width;
cout<<"area of rectangular=", area_rect;

cout<<"Calculate area of triangle.";
cout<<"Enter base=";
cin>>base;
cout<<"Enter height";
cin>>height;
area_triangle= 1/2 * base * height ;
cout<<"area of triangle=", area_triangle;

cout<<"Calculate area of circle.";
cout<<"Enter radius=";
cin>>radius;
area_circle= 3.14;

cout<<"area of circle=", area_circle;
}

No comments:

Post a Comment