I have this C program that needs to calculate the area of a circle that a user inputs. I have to use this before the main function:
void area_circum(double radius, double *area, double *circum);
I'm having trouble getting the program to work. I'm using the main function and another one called area_circum();
This is what I have right now:
#include <stdio.h>
void area_circum(double radius, double *area, double *circum);
int main(void) {
double radius, area, circum;
printf("Please enter the radius of the circle: ");
scanf("%f", &radius);
area_circum(radius, area, circum);
printf("Area of circle : %0.4f\n", area);
return 0;
}
void area_circum(double radius, double *area, double *circum) {
double PIE = 3.141;
double areaC = 0;
areaC = PIE * radius * radius;
}
When I build it and run it, it works, I input a number, but then it returns 0.00
#include <stdio.h>
void area_circum(double radius);
int main() {
double radius;
printf("Please enter the radius of the circle: ");
scanf("%lf", &radius);
area_circum(radius);
return 0;
}
void area_circum(double radius) {
double PIE = 3.141;
double areaC = 0;
areaC = PIE * radius * radius;
printf("Area of circle : %0.4f\n", areaC);
}