Using while or do-while. The Area of a Circle = pi *(r*r). Where pi=3.1415 and r=Radius, Make a program that will input Radius and compute and display the Area. Your program will be terminated if input zero in the radius.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float const pi=3.1415;
float r=1;
while(r>0){
cout<<"Enter the raduius of the circle: ";
cin>>r;
if(r>0){
float area=pi*r*r;
cout<<fixed<<"The Area of a Circle = "<<setprecision(2)<<area<<"\n\n";
}
}
return 0;
}
Comments
Leave a comment