C++ Chapters

C++ Program to Find Volume and Surface Area of Sphere.

Structure of C++ Programs - Overview
#include <iostream>
using namespace std;

int main()
{
    float Radius, Area, Volume, PI = 3.14;
    
    cout << "Enter Radius of Sphere : ";
    cin >> Radius;
    
    Area = 4 * PI * Radius * Radius;
    Volume = 4 * PI * Radius * Radius * Radius / 3;
    
    cout << "\n\nArea of Sphere is : " << Area;
    cout << "\nVolume of Sphere is : " << Volume;
    
    return 0;
}

Output :
Enter Radius of Sphere : 10

Area of Sphere is : 1256
Volume of Sphere is : 4186.67

Description :

Volume of sphere can be calculated as
Volume = 4 x Π x R 3/3
Π = 3.14 (GREEK CAPITAL LETTER PI)
R = Radius of Sphere

Area of sphere can be calculated as :
Area = = 4 x Π x R 2


Leave a comment
Recent Comments
No Comments