Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Thursday, 28 March 2019

Print “Even” or “Odd” without using conditional statement

Question:

Print “Even” or “Odd” without using a conditional statement

C program:

#include<stdio.h>
int main()
{
    int no;
    printf("Enter a no: ");
    scanf("%d", &no);
    (no & 1 && printf("odd"))|| printf("even");
    return 0;
}

Output:

Enter a no: 45
odd

0 comments:

Post a Comment