Thursday, 28 April 2011

Odd or Even number

Given a positive number n print whether the number is Even or Odd without using any conditional and comparison operators.




int main()
{
int number;
char* names[2] = {"Even","Odd"};
printf("Enter a positive number:");
scanf("%d", &number);
printf("\n%d is %s number\n", number, names[number % 2]);
}



No comments:

Post a Comment