lundi 22 juin 2015

How does this code print odd and even?

#define MACRO(num, str) {\
            printf("%d", num);\
            printf(" is");\
            printf(" %s number", str);\
            printf("\n");\
           }

int main(void)
{
    int num;

    printf("Enter a number: ");
    scanf("%d", &num);

    if (num & 1)
    {
        MACRO(num, "Odd");
    }
    else
    {
        MACRO(num, "Even");
    }
    return 0;
}

Please explain the above code (if/else condition and how it prints "Odd" and "Even")

Aucun commentaire:

Enregistrer un commentaire