I have a very simple code problem.
Basically i want even numbers between 4-20, and asks again if its not.Code:#include <stdlib.h> #include <stdio.h> int main (){ int r, c; while (1){ printf ("Indicate the size of the play board (must be even numbers between 4-20)\nEnter row column: "); scanf ("%d %d", &r, &c); if (((r%2) == 0)&& ((c%2)==0)&&(c>=4)&&(c<=20)&&(r>=4)&&(r<=20)) break; else printf ("Invalid input. \n\n"); _sleep (500); } return 0; }
However when i enter a symbol, it goes haywire, and it doesn't ask the user and just loop itself.
Why is this and how do i fix this?