Answer to Question #244000 in C for theblacksun

Question #244000

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. 


"A = 2\\pi rh + 2\\pi r^2"

r = radius

h = height


1
Expert's answer
2021-09-29T04:44:46-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS