C Program Volume Of Cuboid | C Programs

C Program to find the volume of cuboid, check out our code here on how to find the volume of cuboid in C Programming. We wrote the following program in three different ways, using pointers, functions, and macros.

Using Standard

1)The formula for volume of cuboid is v=l*b*h,using this standard formula we are calculating volume.

2)Taking the length,breadth,height and substitute   those values into variables “length,breadth,height” .

3)Calculated value will be store into the variable “volume”

output:

Using Functions

1)float volume(float l,float b,float h)

{return (i*b*h);} is the body of function.

2)We are calling the function using volume(l,b,h),then cursor goes to function body and calculate the volume and return the value.

3)the return value will store into the variable “v”.

output:

Using Pointers

1)*i,*b,*h,*v are pointer variables , float volume(float *l,float *b,float *h,float *v) function having the pointers as arguments.

2)we are calling the function  using “volume(&l,&b,&h,&v)” by passing addresses of l,b,h,v

3)volume (float *l,float *b,float *h,float *v) function calculate the volume and return the value,that return value will store into pointer variable *v.

output:

Using Macros

1)Here volume(l,b,h) is symbolic name  to l*b*h

2) volume(l,b,h)replaced with that expression given at #define.

output:

Add a Comment

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