C Program To Find Area Of Semi Circle | C Programs

How to write a code in C – to find out the area of semi circle. Here we wrote the code in four different ways so that you can opt for any one as per your wish. Do check it out.

Using Standard Method

1)For calculating the area of semi circle we need radius of circle.

2)The value of radius will store into the variable “r”.

3)By substituting the “r” value into the formula then we will get area of semi circle,that will be assigned to the variable “area”

output:

Using Function

1)We are using the function float area(float r) to calculate area of semi circle,the return type of this function is float.

2)Using area(r)we are calling the function which is having float type argument.

3)The called function area(float r) calculate the area of semi circle and returns the value,the return value will be assigned to the variable “a”.

output:

Using Pointers

1)We are calling the function by passing addresses as arguments using area(&r,&a)

2)Then called function area(float *r,float *a) which is having pointers as arguments will calculate the area of semi circle,and that value will store into the variable “a”

output:

Using Macros

1)area(r) is symbolic name to the expression (22*r*r)/(2*7).

2)area(r)replaced with that expression given at #define.

output:

Add a Comment

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