What is wrong with this code? The while loop continues to run even if a ‘1’ or ‘2’ is typed.
#include "stdio.h"
void helper(void);
int main() {
int s;
scanf("%d", &s);
while(s!=1 || s!=2) {
helper();
scanf("%d", &s);
}
return 0;
}
void helper(void) {
printf("Please use 1 or 2 as option");
}
Any number is either not equal to one or not equal to two: you can be certain of that 🙂
What you probably wanted to write was
&&.