Osho
2014-04-13 05:04:38 UTC
In the code everything runs fine, while loop if statement, but "else" statement is not working properly it's printing the output twice.
Here's my code
#include
#include
main()
{
char players;
printf("\nWelcome to Darts");
printf("\nYou want to play single player(s) or double player(d): ");
scanf("%c",&players);
while(players != 's' || players != 'd'){
if(players == 's'){
printf("You choosed single player");
break;
}
if(players == 'd'){
printf("You choosed double player");
break;
}
else{
printf("Type 's' for single player and 'd' for double player: ");
scanf("%c", &players);
}
}
getch();
}
** If user inputs 's' or 'd' it runs fine, but when user inputs something else than 's' or 'd' it prints
"Type 's' for single player and 'd' for double player: " Twice. This line is in else statement