Skip to main content
deleted 2 characters in body
Source Link
Ajinkya
  • 855
  • 1
  • 10
  • 32

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\n""%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

This is my Code

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

int main(void) {
    int num;
    printf("Enter a number:\n");
    scanf("%d\n",&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

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
added 233 characters in body
Source Link
Ajinkya
  • 855
  • 1
  • 10
  • 32

This is my Code

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

int main(void) {
    int num;
    printf("Enter a number:\n");
    scanf("%d\n",&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...WHatWhat 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

This is my Code

int main(void) {
    int num;
    printf("Enter a number:\n");
    scanf("%d\n",&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?

This is my Code

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

int main(void) {
    int num;
    printf("Enter a number:\n");
    scanf("%d\n",&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
Source Link
Ajinkya
  • 855
  • 1
  • 10
  • 32

why is printf not called when expected?

This is my Code

int main(void) {
    int num;
    printf("Enter a number:\n");
    scanf("%d\n",&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?