+ 3
Challenge:Input any number and find whether the number is even or odd without using any logical and relational operators..
6 Answers
+ 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 ....
+ 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;Ā Ā
}
+ 2
n=str(input())
if n[-1] in list(range(0,10,2)):
print('even')
else:
print('odd')
+ 1
https://code.sololearn.com/c07vjWirgFUo/?ref=app Can you check it?