Hi I hope I'm posting in the right forum but I'm having trouble with a Computing 1 homework assignment. Were supposed to have the user enter an integer: 100, and keep them in a while loop until they post 100.
Here's my program:
Code:
#include <stdio.h>
int main(int argc, const char * argv[]) {
int number;
printf("Please enter integer 100: ");
int numOfConversion = scanf("%d", &number);
while (numOfConversion == 0 || number != 100) {
printf("Please enter integer 100: ");
numOfConversion = scanf("%d", &number);
}
printf("I got the number: %d\n", number);
return 0;
}
It works for integers but when I enter anything but an integer it just repeats "Please enter integer 100: " over and over. According to the lectures its supposed to work? Apparently its supposed to work using just a while loop and I cant find anything that fixes this problem using one while loop. Any help is much appreciated and thanks in advance!