AD1

Sunday, 5 February 2017

Even or Odd

Write a C program to check if any entered number is even or odd without the use of conditional statements (if,else)

#include <stdio.h>
int main(void) {
printf("enter your number (assume it must be positive integer)\n");
int input;
scanf("%d",&input);
char choise[2]={'E','O'};// O for Odd and E for Even
printf("%d is %c",input,choise[input%2]);
return 0;
}
view raw evenorodd.c hosted with ❤ by GitHub

No comments:

Post a Comment