+ 3

Challenge:Input any number and find whether the number is even or odd without using any logical and relational operators..

14th Mar 2018, 2:26 PM
looper
looper - avatar
6 ответов
+ 8
👉take the number as String , and take out last character & use .equals("0")||.equals ("2")||.equlas ("4") ....equals ("8") //well here I used some restricted operators 👉make use of modulo(%) 👉run a loop & substact 2 repeatedly if num >0 , now compare num+"" with "1" using .equals method ... if true then odd else even //thinking ....
14th Mar 2018, 2:30 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
#include <stdio.h>   int main() {     int number;           //input an integer number     printf("Please input an integer number: ");     scanf("%d",&number);               //check 0th bit of number is 1 or 0     (number & 0x01) ? printf("%d is an EVEN Number.”, number) :  printf("%d is an ODD Number.",number) ;           printf("\n";)     return 0;   }
16th Mar 2018, 1:45 AM
madhavi vemula
+ 2
n=str(input()) if n[-1] in list(range(0,10,2)): print('even') else: print('odd')
10th Jul 2018, 9:02 AM
Sebastian Zepeda
Sebastian Zepeda - avatar
15th Mar 2018, 4:38 PM
Muza
Muza - avatar