CBSE Class 11 Computer Science
Question 136 of 161
Flow of Control — Question 13
Back to all questions 13
Question Question 13
Write a program to take an integer a as an input and check whether it ends with 4 or 8. If it ends with 4, print "ends with 4", if it ends with 8, print "ends with 8", otherwise print "ends with neither".
Solution
a = int(input("Enter an integer: "))
if a % 10 == 4 :
print("ends with 4")
elif a % 10 == 8 :
print("ends with 8")
else :
print("ends with neither")Output
Enter an integer: 18
ends with 8