Skip to content
Home » Find Area of Circle Using Pointer & Function in C

Find Area of Circle Using Pointer & Function in C

Learn about Find Area of Circle Using Pointer & Function in C in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C program to find Area of Circle Using Pointer & Function

Here, we assign values of radius to pointer pr and declare pointer parea to store calculate value in it . As we know the area of circle formula , user-defined function circlearea is to be defined . function is called using pointer as parameter to that function.

#include<stdio.h>
#define PI 3.14
int circlearea(double *r, double *area);
int main()
{
  double r, area;
  double *pr, *parea;
  pr= &r, parea= &area;
  printf("Enter radius: ");
  scanf("%lf",pr);
  circlearea(pr, parea);
  printf("Area of radius %lf = %.2lf\n",*pr, *parea);
  return 0;
}
int circlearea(double *r, double *area)//function for calculating area
{
  *area = PI * *r * *r;
}

Output:

Enter radius: 14
Area of radius 14.000000 = 615.44

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
C Program to find Area of Circle Using Pointer
Add two Number Using Pointer & Function in C