C Program Area Of Trapezium | C Programs

From the list of C Programs another code to find the area of trapezium. Do check it out and leave a comment here, if you do have any doubts and also post your code below, if you came up with the new innovative code.

Using Standard Method

1)For area of trapezium we need the values of base1,base2,height.

2)By substituting the values of base1,base2,height into the formula area=((base1+base2)/2)*height,we will get area of trapezium,the value will store into the variable “area”.

output:

Using Function

1)We are using float area(float a,float b,float h) function to calculate the area of trapezium.

2)We are calling the function using area(a,b,h),then called function will calculate the area of trapezium and return the value.

3)The return value will assigned to the variable “A”.

output:

Using Pointers

1)We are  passing the addresses as arguments in the calling function AOT(&b1,&b2,&h,&area).

2)The called function AOT(float *a,float *b,float *h,float *area) calculate the area by retrieving the values at that addresses.

3)The calculated value will store into the pointer variable “area”.

output:

Using Macros

1)area(b1,b2,h) is symbolic name to the expression ((b1+b2)/2)*h

2)area(b1,b2,h)replaced with that expression given at #define.

output:

Add a Comment

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