I have a program to write and it is giving me trouble.
It asks the user for inputs such as suggesting which shape they would like to know the area and/or surface are of. This element, I have mastered.
The problem is that when I try to add in while loops to say that the response is invalid, it messes the whole program up.
I need it to say, "Invalid response, please select option 1, 2 3 or 4 etc.
I am writing the loop as follows:
printf("Please enter 1 for area or 2 for surface area: ");
scanf("%i",&menu1);
while(menu1!=1&&menu1!=2) {
printf("Invalid option. Please enter 1 for area or 2 for surface area: ");
scanf("%i",&menu1);
}
The problem is now when the user makes a valid response, "Invalid response" appears. How to fix this?