why is printf not called when expected?

Viewed 334

This is my Code [Note: I am using Eclipse for C/C++ on Windows Platform]

#include <stdio.h>
#include<stdlib.h>

int main(void) {
    int num;
    printf("Enter a number:\n");
    scanf("%d",&num);
    if(num%2==0)
        printf("Number is Even");
    else
        printf("Number is Odd");
    return EXIT_SUCCESS;
}

Here I have to enter an Integer first only then printf is called... I want to call printf first before I enter an Integer...What am I doing wrong here?

for example this is the output that I get

6
Enter a number:
Number is Even

and expected output is

Enter a number:
6
Number is Even
1 Answers
Related