Write a c program to find the area of circle Using Functions

 TASK-

Write a c program to find the area of circle with formula as below 

 Area of the Circle = Ï€r2

In which declare π as a global variable, and make a function of area_of_cirlce and pass the value of r to the function and print.



CODE:

#include<stdio.h>
void area_of_circle(float r);


float p=3.14;  //value of pie is declared as globle variable


int main(){
float rad;


printf("Enter the radius of circle: ");
scanf("%f",&rad);


area_of_circle(rad); //calling the function


getchar();
return 0;
}


void area_of_circle(float r)
{
float area;
area=(p)*r*r;    //Formula of area of circle
printf("\n\n The area_of_circle with %0.2f radius is %0.2f",r,area);
}

Expected Output:





NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

Post a Comment (0)
Previous Post Next Post