2. Write a Program that input radius of a sphere from the user. Calculate its volume and surface area using the Formula.
Chapter No: 4
Input & Output
Programming Exercises Solution
Q No 2 :
Write a Program that input radius of a sphere from the user. Calculate its volume and surface area using the Formula Area = 4Ï€(r*r) and
circumference = 4 / 3π(r*r*r) where π = 3.14.
Solution :
#include<iostream>
#include<conio.h>
#include<math.h>
void main()
{
const float PI=3.14;
float area, circumference, radius;
cout<<"Input radius of spehere: ";
cin>>radius;
area = 4*PI*pow(radius,2);
circumference = (4/3)*PI*pow(radius,3);
cout<<"Area: "<<area<<endl;
cout<<"Circumference: "<<circumference<<endl;
getch();
}
Previous Program :
Next Post :
3. Write a program to find out the area of a triangle when three sides a, b and c of the triangle are given.
noice dear
ReplyDelete