Saturday, 8 February 2014

c program to find even or odd with out using if else

c program to find even or odd with out using if else

/*Print “Even” or “Odd” without using conditional statement
Write a C/C++ program that accepts a number from the user and prints “Even” if the entered number is even and prints “Odd
if the number is odd.
    Your are not allowed to use any comparison (==, <, >..etc)
     or conditional (if, else, switch,
    ternary operator,..etc) statement.*/
    printf("tjis cod by ameer hamza");

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

No comments:

Post a Comment