Given the values for radius and height of a Cylinder, code a C program to calculate the Surface Area of the Cylinder. Function CalculateArea must accept height and radius as parameters.
r = radius
h = height
#include <stdio.h>
#include <math.h>
float CalculateArea(float r, float h) {
return 2.f * M_PI * r * h + 2.f * M_PI * r * r;
}
int main()
{
float r, h;
printf("Radius: ");
scanf("%f", &r);
printf("Height: ");
scanf("%f", &h);
printf("Cylinder's Area: %0.4f\n", CalculateArea(r, h));
return 0;
}
Comments
Leave a comment