Define a macro with one parameter to compute the volume of a sphere. Write a C program using this macro to compute the volume for spheres of radius 5, 10 and 15 meters.
Program Code:
#include<stdio.h>
#include<math.h>
#define PI 3.142
#define volume(r) ((4/3.0)*PI*pow(r,3))
void main()
{
int r;
float v;
scanf("%d",&r);
v=volume(r);
printf("\n volume of the sphere v=%.3f",v);
}
Post A Comment:
0 comments: