Consider the following C++ program in which the statements are in the incorrect order.
Rearrange the statements so that it prompts the user to input the radius of a circle and outputs the area and circumference of the circle.
#include <iostream>
{
int main()
cout << "Enter the radius: ";
cin >> radius;
cout << endl;
double radius;
double area;
using namespace std;
return 0;
cout << "Area = " << area << endl;
area = PI * radius * radius;
circumference = 2 * PI * radius;
cout << "Circumference = " << circumference << endl;
const double PI = 3.14;
double circumference;
}
#include <iostream>
using namespace std;
int main()
{
const double PI = 3.14;
cout << "Enter the radius: ";
double radius;
cin >> radius;
double area;
area = PI * radius * radius;
double circumference;
circumference = 2 * PI * radius;
cout << endl;
cout << "Area = " << area << endl;
cout << "Circumference = " << circumference << endl;
return 0;
}
Comments