Hello everyone. I am having trouble with my C++ program. My program asks the user to enter any number greater than 0 and less than 20, and if the user enters any number(s) outside the acceptable range, the output should display:
input outside of exceptable range > 0 and < 20
length: 1 width: 1 area: 1 perimeter: 1
But in my program, this output displays no matter what the user types (even if the numbers are in the acceptable range, when it should be displaying the length and width the user enters and also displaying the calculated perimeter and area whenever the user enters number(s) in the acceptable range. Can someone please help? Here is my code:
The functions you are calling to try to calculate whether the values are within the acceptable range don't do anything useful; they always return 0, so they never change based on the input. Those functions themselves also seem to imply you don't really understand how functions work; you are declaring some uninitialized variables, calculating a boolean result that you immediately ignore, then unconditionally return 0.
Okay, so this time I tried this, but get get displayed from the prompt asking me the length and width, but it does not display the length, width, calculated area and perimeter. What to do now?
The lengths and widths you have in each function may have the same names, but they are all different variables. I really think you need to re-read whatever material you have on functions, trying to see what they say on identifier scopes.
I know they are different variables, that is why I declared them in each function and that is acceptable. I do not know what the problem is even after reading it. I could declare them globally, but my professor does not want us to do that yet.