i am a beginner at C programming and I was trying out a basic function to produce the area of a circle. the radius had to be taken as input from the user. the code is as follows :
#include<stdio.h>
#include<math.h>
float areacircle(float r);
float area;
float r;
int main(){
printf("enter the radius of the circle: ");
scanf("%f",r);
areacircle(r);
return 0;
}
float areacircle(float r){
area = 3.14*r*r;
printf("the area of the circle is : %f",area);
}
whenever the user enters any radius, the output is always 0.00. why is this happening ? the output should show the area of the circle according to the radius which has been entered.
New contributor
Tishya Misra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1