Q:

Write a program in C++ to calculate the volume of a sphere

0

Write a program in C++ to calculate the volume of a sphere

Sample Output:

 Calculate the volume of a sphere :                                    
---------------------------------------                                
 Input the radius of a sphere : 6                                      
 The volume of a sphere is : 904.32

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
using namespace std;

    int main()
    {
    	int rad1;
    	float volsp;
		cout << "\n\n Calculate the volume of a sphere :\n";
		cout << "---------------------------------------\n";		
        cout<<" Input the radius of a sphere : ";
    	cin>>rad1;
    	volsp=(4*3.14*rad1*rad1*rad1)/3;
        cout<<" The volume of a sphere is : "<< volsp << endl;
        cout << endl;
        return 0;
    }

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now