Program to find volume of sphere

0
28
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.142
void main()
{
   float r,v;                   /* r for radius and v for volume*/
   clrscr();
   printf(“enter radius of sphere\n);
   scanf(“%f”,&r);        /*  inputting the value from keyboard*/
   v=4.0/3*pi*pow(r,3);
               /* pow() math function used for r to the power of 3 */
               /* the value of 4.0/3 leads to a correct answer can be written as      
                   v=4*pow(r,3)*pi/3 priority of operators */
   printf(“\n volume of sphere with radius %2f=%.4f”,r,v);
              /*gives the result with 2 & 4 decimal places */
   getch();
}
   Output:
   enter radius of sphere
   6.52
   Volume of sphere with radius 6.52=1160.9978

Program to find volume of sphere write a program to find volume of sphere in c program to find volume of a sphere c Program to find volume of sphere write a program to find volume of a sphere c program to find the volume of a sphere:

LEAVE A REPLY

Please enter your comment!
Please enter your name here