Ask Question
31 August, 21:27

Consider the following C+ + program in which the statements are in the incorrect order. Rearrange the statements so that itprompts the user to input the radius of a circle and outputs the area and circumference of the circle-#include {int. main () cout <> radius; cout << endl; double radius; double area; using namespace std; return 0; cout << "Area = ' << area << endl; area - PI * radius * radius;

+1
Answers (1)
  1. 31 August, 22:56
    0
    The correct program to this question can be given as:

    Program:

    //header file

    #include / /include header file

    using namespace std;

    //main

    int main () / /defining method main

    {

    double radius, area=0; / /defining variables

    double PI=3.14; / /defining variable PI and assign value

    cout <<"Enter the radius: "; / /message

    cin >> radius; / /input value by user

    area = PI * radius * radius; / /formula to calculate area

    cout << "Area: "<< area << endl; / /print area

    return 0;

    }

    Output:

    Enter the radius: 3.0

    Area: 28.26

    Explanation:

    In the above program code, a header file is included. In the next line, the main method is defined, which contain three double type variable that is "radius, area, and PI".

    The radius variable is used to take input by the user, and the area variable is to calculate the area of the circle, and the PI is used to hold a constant value, which is "3.14". After taking user input in radius variable the area variable has used the formula of the circle, which calculates a value and in the last print, the function uses "cout", that prints area variable value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the following C+ + program in which the statements are in the incorrect order. Rearrange the statements so that itprompts the user ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers