In: Computer Science
Write c code program for the following
Write a function, circle, which takes the radius of a circle from the main function and assign the area of the circle to the variable, area, and the perimeter of the circle to the variable, perimeter. Hint: The function should have three variables as input. Since the contents of the variables are to be modified by a function, it is necessary to use pointers.
Please type out the full usable program. Thank you.
#include<stdio.h>
#define PI 3.14
//function to calculate area and perimeter and assign to the
call by reference arguments
int circle(float radius, float *area, float *perimeter)
{
*area = PI * radius * radius;
*perimeter = 2 * PI * radius;
}
int main()
{
float radius,area,perimeter;
printf("Enter radius: ");
scanf("%f",&radius);
circle(radius,&area,&perimeter);
printf("Area = %.2f\n",area);
printf("Perimeter = %.2f\n",perimeter);
}
//Code Snippet
//output