In this, we are going to see how to find Surface Area of Sphere using C++ program.

The formula to calculate is,

Surface Area of Sphere = 4 * π * radius * radius 

The Code given below can be used in Turbo C++ Compiler.

#include<iostream.h>
#include<conio.h>

void main()
{
    clrscr();
    float area, radius, pi=3.142;
    cout<<"This program is for Surface Area of Sphere\n";
    cout<<"Enter the radius of the sphere\n";
    cin>>radius;

    //formula for Surface Area of Sphere is 4*Ï€*radius*radius
    area = 4*pi*radius*radius;
    cout<<"The Surface Area of Sphere with radius "<<radius<<" is = "<<area<<" sq units";
    getch();
}
    
    

The Code given below can be used in g++/gcc Compiler.

#include<iostream>
using namespace std;

int main()
{
    float area, radius, pi=3.142;
    cout<<"This program is for Surface Area of Sphere\n";
    cout<<"Enter the radius of the sphere\n";
    cin>>radius;

    //formula for Surface Area of Sphere is 4*Ï€*radius*radius
    area = 4*pi*radius*radius;
    cout<<"The Surface Area of Sphere with radius "<<radius<<" is = "<<area<<" sq units";
    return 0;
}
    
    

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post