Answer to Question #182997 in C++ for Vincenzo Santoro

Question #182997

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;
}
1
Expert's answer
2021-04-21T12:42:54-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS