Can I impose on this thread to once again provide some help? I am attempting to write a program that will calculate the surface area and volume of a cylinder, based on input values for the radius and height. It wouldn't be so difficult if we weren't also required to create user-defined functions to do pretty much everything. Thus it is roughly twice as long as it needs to be.
/* A program for measuring a cylinder
Created by: Sirus
Purpose: To test user-defined functions
*/
#include <stdio.h>
//Function Declarations
float getRadius();
float getHeight();
float calcArea(float, float);
float calcVolume(float, float);
void printOutput(float, float);
int main (void)
{
//Local declarations
float a;
float b;
float c;
float d;
//Statements
a = getRadius();
b = getHeight();
c = calcArea(a, b);
d = calcVolume(a, b);
//Print the results
printf("\n The cylinder's surface area is: ");
printOutput(c);
printf("\n The cylinder's volume is: ");
printOutput(d);
return 0;
}
float getRadius (void)
{
//Declarations
float numIn;
//Statement
printf("Enter the radius: ");
scanf("%f", &numIn);
return numIn;
}
float getHeight (void)
{
//Declarations
float numIn;
//Statement
printf("\nEnter the height: ");
scanf("%f", &numIn);
return numIn;
}
float calcArea (float x, float y)
{
//Statement
return (((2 * 3.14) * (x * x)) + ((2 * 3.14) * (x * y)));
}
float calcVolume (float x, float y)
{
//Statement
return (3.14 * (x * x) * y);
}
void printOutput(float x)
{
//Statement
printf("%f", x);
return;
}
Anyway, I thought I had everything set up right, but building returned a few errors and it refuses to run. Mostly involving conversions from double to float (wtf? I defined no doubles) and not having enough arguments to call printOutput back in the main function.