write a program to input choice (1 or 2) if choice is 1 print the area of a circle otherwise print the perimeter of circle accept the radius of circle from user
Answers
Answered by
6
# include<iostream.h>
main()
{
int r,opt;
float pi,area,perimeter,
pi=3.14;
cout<<"enter the option";
cin>>opt;
if(opt==1)
{
cin>>r;
area=pi*r*r;
cout<<"area of the circle is"<<area;
}
else is(opt==2)
{
cin>>r;
perimeter=2*pi*r;
cout<<"perimeter of the circle is"<<perimeter;
}
else
cout<<"wrong input";
return 0;
}
main()
{
int r,opt;
float pi,area,perimeter,
pi=3.14;
cout<<"enter the option";
cin>>opt;
if(opt==1)
{
cin>>r;
area=pi*r*r;
cout<<"area of the circle is"<<area;
}
else is(opt==2)
{
cin>>r;
perimeter=2*pi*r;
cout<<"perimeter of the circle is"<<perimeter;
}
else
cout<<"wrong input";
return 0;
}
Similar questions
English,
7 months ago
Computer Science,
7 months ago