How to Find volume of Sphere in C++ (Basics)

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


#include<iostream>

using namespace std;

int main()

{

// A program to calculate volume of sphere((4/3 pr^3)

float r,voul;

int const pi=3.142;

cout<<"Enter radius of spehere :";

cin>>r;

voul=(4*r*r*r*3.142)/3;

cout<<"So the voulme of spehere= "<<voul;

return 0;

}


Output of program would be :




Comments

Post a Comment