Monday, December 27, 2010

Can you tell if the given number is even or odd ?

You have to tell the given number is even or odd, but the condition is you can not use any conditional statements or looping statements (if, for, while, goto etc)..

# include<stdio.h>
void main()
{
char *a[2]={"even", "odd"};
int num;
printf("enter Number:");
scanf("%d",&num);

printf("The number is %s",a[num%2]);
}

No comments:

Post a Comment