# Helpp Do Not Know Where To Start

• 03-12-2009
sjcc
Helpp Do Not Know Where To Start
Write an interactive C or C++ program to calculate the surface area of a cylinder. In the header comment of your code, write the pseudocode for the program. Include a screenshot showing that's you have tested your program.
• 03-12-2009
baccardi
cylinder surface area calculates with formula: 2*pi*R*h + 2*pi*R^2, so the input should be h and R values of cylinder. The program code:

float area, R, h;

area = 2*3.14*R*h + 2*3.14*R*R;

that's all
• 03-12-2009
sjcc
o thats it? thats all that i put in my complier?
• 03-12-2009
laserlight
Of course, you need to write the other parts of the program to actually get it to compile and run. You also need to write the part that reads in input and prints the output.
• 03-12-2009
MK27
Begin with the pseudo-code which apparently you have to write anyway.

The formula for this only involves two variable, radius and height. You don't need <math.h>, but you do need pi, which you can just define this way:
Code:

`#define PI 3.1415`
I would say the pseudo-code involves slightly more than just the formula, btw
• 03-12-2009
sjcc
#include<stdio.h>
#include<math.h>

/*prompt the user for the radius
prompt the user for the height
get the height
compute the surface area of the cylinder
display the value of radius, height and the calculated surface area
*/

int main ()
{

int r;
int h;
double sa;
printf("Enter a value for the radius:");
scanf("%d",&r);

printf("Enter a value for the height:");
scanf("%d",&h);

sa= 2 * M_PI * (r * r) + 2 * M_PI * r * h;

printf( "height is %d\n", h);
printf( "surface area is %f\n", sa);

return (0);

is this right?
• 03-12-2009