+ 3
Challenge:Input any number and find whether the number is even or odd without using any logical and relational operators..
6 Respuestas
+ 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?