#include"stdio.h"
int main()
{
float r, area, perimeter;
float compute(float,float*);
printf("\n enter the radius of the circle:");
scanf("%f",&r);
area=compute(r, &perimeter);
printf("\n AREA = %f", area);
printf("\n PERIMETER = %f", perimeter);
return 0;
}
float compute(float r, float *p)
{
float a;
a=(float)3.1415 * r * r;
*p=(float)3.1415 * 2 * r;
return a;
}
enter the radius of the circle:5
AREA = 78.537506
PERIMETER = 31.415001
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.