I am learning C and having problems with a basic c programming question, below is a simple code with 2 functions, one to calculate area, the other to calculate the perimeter of a circle. The code works if only one function is present, what is wrong?
Code:
#include<stdio.h>
float ar(int); /*function to calculate area*/
float peri(int); /*function to calculate perimeter*/
void main()
{
int radius;
float area, perimeter;
printf("Enter radius : ");
scanf("%d",&radius);
printf("\n");
area = ar(radius);
perimeter = peri(radius);
printf("Area is %f\n",area);
printf("Perimeter is %f\n",perimeter);
getch();
}
float ar(int r)
{ float a = 0.0;
a = 3.14*3.14*r;
return (a);
}
float peri(int rad)
( float p;
p = 2.0 * 3.14 * rad;
return p;
}