My while loop is not working. When it says "Would you like to play another game?", it allows unlimited inputs and doesn't respond to the inputs "1" or "0". can anyone help me find the error here?
Code:
#include <stdio.h>
int main(void)
{
int i;
int j;
int contest();
int personalityTest();
int guessedWeight();
printf("+_+_+_+_+WELCOME TO THE FALL CARNIVAL!_+_+_+_+_\n\n +_+_+_+_+_Which Carnival Game Would You Like To Play?_+_+_+_+_+\n");
printf("1. Pumpkin Contest\n 2. guess your weight\n 3. personality test\n Enter the integer corresponding to your choice:\n");
scanf("%i", &i);
if(i==1)
{
contest();
}
else if(i==2)
{
guessedWeight();
}
else if(i==3)
{
personalityTest();
}
else
{
printf("invalid input!\n\n");
}
printf("\nWould you like to play another game?\n (Enter 1 for Yes, 0 for No)\n");
scanf("%i", &j);
while(j==1);
{
printf("+_+_+_+_+_Which Carnival Game Would You Like To Play?_+_+_+_+_+\n");
printf("1. Pumpkin Contest\n 2. guess your weight\n 3. personality test\n Enter the integer corresponding to your choice:\n");
scanf("%i", &i);
if(i==1)
{
contest();
}
else if(i==2)
{
guessedWeight();
}
else if(i==3)
{
personalityTest();
}
else
{
printf("invalid input!\n\n");
}
printf("\nWould you like to play another game?\n\n (Enter 1 for Yes, 0 for No)\n");
scanf("%i", &j);
}
if(j==0)
{
return 0;
}
}