How can I break the do while
loop here in my code? The program should loop until the user inputs a valid year from the category.
When I enter the valid input, the printf
still shows up even if it is meant to stop.
Here is the code below:
#include <stdio.h>
int main()
{
float year;
do {
printf("Please input your year of birth :");
scanf("%f", &year);
if ((year >= 1946) && (year <= 1964))
printf("You belong to the baby boomer generation \n");
else if ((year >= 1965) && (year <= 1980))
printf("You belong to the Generation X \n");
else if ((year >= 1981) && (year <= 1996))
printf("You belong to the Millenials/Generation Y \n");
else if ((year >= 1997) && (year <= 2012))
printf("You belong to the Zoomers/Generation Z \n");
} while(1946 > year < 2012);
}