Brijmohan lal Sahu - Facebook
ads
ads

Saturday, November 8, 2014

Program to take the radius of a sphere as input and print the volume and surface area of the sphere in C++.

circle


Code Box
---------------------------------------------

/*Program to take the radius of a sphere as input and print
the volume and surface area of the sphere */

#include<iostream.h>
#include<conio.h>
void main()
{
float radius,volume,sarea;
clrscr();

cout<<"\nEnter radius of circle:";
cin>>radius;

cout<<"\nVoume=";
volume=(4/3)*3.413*radius*radius*radius;
cout<<volume;

cout<<"\n\n";

sarea=4*3.412*radius*radius;
cout<<"\nSurface area ="<<sarea;

cout<<"\n";
getch();
}


--------------------------------------------

Code Box 2
---------------------------------------------

/*Program to take the radius of a sphere as input and print
the volume and surface area of the sphere */

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float radius,volume,sarea;
clrscr();

cout<<"\nEnter radius of circle:";
cin>>radius;

cout<<"\nVoume=";
volume=(4/3)*3.413*(pow(radius,3));
cout<<volume;

cout<<"\n\n";

sarea=4*3.412*(pow(radius,2));
cout<<"\nSurface area ="<<sarea;

cout<<"\n";
getch();
}



No comments:

Post a Comment