C programming windows console applicationSolutioninclude inc
C++ programming windows console application
Solution
#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<iomanip>
using namespace std;
double rectangle();
double cylinder();
double circle();
int main(){
int choice =0;
double ans=0.0;
cout<< \"1. Area of rectangle:\" <<endl;
cout<< \"2. Area of cylinder:\" <<endl;
cout<< \"3. Area of circle:\" <<endl;
cout<< \"4. Terminate program:\" <<endl;
cout<<\"enter your choice\"<<endl;
cin>> choice;
switch(choice)
{
case 1 :
ans=rectangle();
break;
case 2 :
ans=cylinder();
break;
case 3 :
ans=circle();
break;
case 4 :
return 0;
Default:
cout<<\"The value not valid\"<<endl;
}
cout<<fixed<<showpoint;
cout<<setprecision(2);
cout<<\"The answer is: \"<<ans<<endl;
getch();
return 0;
}
double rectangle(){
double area=0.0;
double length=0.0;
double breadth=0.0;
cout<<\"enter length of rectangle\";
cin>>length;
cout<<\"enter breadth of rectangle\";
cin>>breadth;
area=length*breadth;
return area;
}
double cylinder(){
double area=0.0;
double radius=0.0;
double height=0.0;
cout<< \"enter radius of circle\";
cin>>radius;
area=3.14*radius*radius;
return area;
}
double circle(){
double area=0.0;
double radius=0.0;
double height=0.0;
cout<<\"enter radius of circle\";
cin>>radius;
cout<<\"enter height of circle\";
cin>>height;
area= 2*3.14*radius*radius*height+2*3.14*radius*radius;
return area;
}

