Write a C++ program to find Volume of sphere and Area of sphere (logic explained step by step)

Write a C++ program to find Volume of sphere and Area of sphere

Here is the C++ program to to find Volume of sphere and Area of sphere .  It takes input of radius of sphere and calculate the volume and area of sphere. You all should have in mind how it works exactly. Here is the algorithm.
Steps
User side:
1: User asked to enter the radius.
2: Program display the volume and sphere.
Developer side
1: Declare variables that are going to be used in program.
2: Input the radius of sphere from user.
3: Calculate the volume and store it in a variable 'v'. Formula to calculate the volume is as follows   v=(4/3)*(pi*r*r*r);
4: Show the volume on screen.
5: Calculate the Area and store it in a variable 'a'. Formula to calculate the area is as follows  a=pi*r*r;
6: Program end


Code

#include<iostream>
using namespace std;
const float pi=3.14;
int main()
{      //Declare variables
       float r;
       double v;
       double a;
       //Input radius
       cout<<"Input radius"<<endl;
       cin>>r;
       //Volume of sphere = 4/3(πr3)
       v=(4/3)*(pi*r*r*r);
       cout<<"Volume of sphere"<<v<<endl;
       //Area of sphere = πr2     
       a=pi*r*r;
       cout<<"Area of Circle"<<a<<endl;
       system ("pause");
       return 0;

      
}

 Ouptput

Comments