c program Volume of sphere

c program Volume of sphere(standard)

1)We have the formula for volume of sphere is v=(4*22*r*r)/(7*3);

2)scanf(“%f”,&r) ,scanf function reads the r value , r will be store into the variable “r”.

3)The r value will substitute into the formula , the calculated value will be store into v, v value will be displayed

using printf(“VOS:%f\n”,v);



c program Volume of sphere(function)

1)we are calling the function using volume(r).

2)The  called function float volume(float r) will calculate the volume and return the value to v=volume(r).

3)v hold the return value.



c program Volume of sphere(pointers)

1)We are calling the function by passing addresses using volume(&r,&v).

2)volume(float *r,float *v) having pointer variables r,v. This function calculate the volume of sphere and the value will store into variable v.

3)Using printf statement v value will be displayed.


c program Volume of sphere(macros)

1)The symbolic name to the formula (4*22*r*r*r)/(7*3) is area(r)

2)area(r) replaced by  the expression given at #define



Add a Comment

Your email address will not be published. Required fields are marked *