Write a C program to check if any entered number is even or odd without the use of conditional statements (if,else)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
} |
No comments:
Post a Comment