Given the values for radius and height of a Cylinder, code a C program to calculate Surface Area of the Cylinder. Function CalculateArea must accept height and radius as parameters.
#include<stdio.h>
float CalculateArea(float radius,float height){
const float PI = 3.14159265359;
return (2 * PI * radius * height) + (2 * PI * radius * radius);
}
int main() {
float radius, height, area;
printf("Enter radius of the cylinder: ");
scanf("%f", &radius);
printf("Enter height of the cylinder: ");
scanf("%f", &height);
area =CalculateArea(radius,height);
printf("Surface area of the cylinder is %.4f\n", area);
getchar();
getchar();
return 0;
}
Comments
Leave a comment