Answer to Question #180278 in C++ for Puja

Question #180278

Write a program that defines the named constant PI, const double

PI = 3.14159;, which stores the value of p. The program should use PI

and the functions listed in Table 6-1 to accomplish the following:


a. Output the value of Pi Output the value of Pi.

b. Prompt the user to input the value of a double variable r, which stores the radius of a sphere. The program then outputs the following:

i.   The value of 4Pir2, which is the surface area of the sphere.

ii.   The value of (4/3)Pir3, which is the volume of the sphere


1
Expert's answer
2021-04-11T01:14:42-0400
#include<bits/stdc++.h>
#define PI 3.14159
using namespace std;
int main()
{
    cout<<"Value of PI = "<<PI;
    double r,sa,vol;
    cout<<"\nEnter the radius of sphere ";
    cin>>r;
    sa=4*PI*r*r;
    vol=(4*PI*r*r*r)/3;
    cout<<"\nSurface area of sphere = "<<sa;
    cout<<"\nVolume of sphere = "<<vol;
}

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