Check if the number is odd or even
Aim:
Implement
a program to check if the number is odd or even.
Algorithm:
1.Start
2.If (n%2=0) then
3.Print number is even
4.else
5.Print number is odd
6.Stop
Program:
# Python program to
check if the input number is odd or even.
# A number is even if
division by 2 give a remainder of 0.
# If remainder is 1, it
is odd number.
num =
int(input("Enter a number: "))
if (num % 2) == 0:
print “Even"
else:
print “Odd”
Output :
Enter a number: 43
Odd
0 Comments:
Post a Comment