Hello all. Basically, I'm new to C programming but not necessarily to programming. I'm a college student and took a semester of Java, so I understand many of the fundamentals. However, I'm having issues with the while loop in my code not initializing if the condition is met.
Obviously, there is more to the program, but this needs to be solved before I can move on. Some context: The idea of the program is to calculate the volume and surface area of a cylindrical tank with concave spheres on the ends. However, the length can only be between 10 and 20, and the radius between 3 and 6. Also, should the radius be more than half the length of the container, the tank would not be possible because the concave spheres would overlap.
I thank anyone in advance who can offer help. Thanks!
#include <stdio.h>
#define PI 3.141593f
int main(void)
{
float length = 0.0;
float radius = 0.0;
float check = 0.0;
printf("ACME Truck Company\n");
printf("This program will calculate the volume and surface area of the x-11 cylindrical tank.");
printf("\nEnter the length of the tank (feet): ");
scanf("%f", &length);
printf("Enter the radius of the tank (feet): ");
scanf("%f", &radius);
while(length <= 10.0 && length >= 20.0) {
printf("User input is invalid, please enter a value between 10 and 20: ");
scanf("%f", &length);
check = (length / 2);
if(check <= radius) {
printf("User input is invalid, please enter a value between %f and 20: ", length);
scanf("%f", &length);
}
}
}
Obviously, there is more to the program, but this needs to be solved before I can move on. Some context: The idea of the program is to calculate the volume and surface area of a cylindrical tank with concave spheres on the ends. However, the length can only be between 10 and 20, and the radius between 3 and 6. Also, should the radius be more than half the length of the container, the tank would not be possible because the concave spheres would overlap.
I thank anyone in advance who can offer help. Thanks!