I am new to programming . I am trying to do an assignment but the code doesn't do anything after the first input to scanf . ( I am coding in VS code and i have to run the program again to get the result . until then nothing happens. ) I wrote an another simple code to check if anything is wrong with the code or if it is a IDE problem . Here it is :
#include <stdio.h>
int main () {
int a, b;
printf("Enter an positive Integer : ");
scanf("%i ", &a);
b = a%2;
if (b == 0) {
printf("The given number is an Even Integer. \a\n ");
} else {
printf("The given Integer is an Odd integer. \n");
}
return 0;
}
After the input if I enter a character or a number and then press 'Enter' then it prints out the result. Or else I have to run the program to print the result .
( I am using code runner ).
I referred to similar questions on stack overflow and applied some solutions like ' removing the \n in scanf ' and 'leaving a space before the %i in scanf ' but nothing works .
Your help is MUCH appreciated.