input of a number and print whether the last digit is 5 or not
Answers
Answered by
8
The given problem is solved using language - QBASIC.
CLS
INPUT "Enter a number: "; N
LD = N MOD 10
IF LD = 5 THEN
PRINT "The last digit is 5."
ELSE
PRINT "Last digit is not 5."
END IF
END
- Line 1: Clears the screen.
- Line 2: Accept the number from the user.
- Line 3: Calculate the last digit of the number entered.
- Line 4: Check if last digit is 5 or not.
- Line 5: If true, last digit is 5. Print a message.
- Line 6: Else part.
- Line 7: When condition is false, last digit is not 5.
- Line 8: End of if-else.
- Line 9: End of program.
See the attachment for output.
Attachments:
anindyaadhikari13:
Thanks for the brainliest :)
Answered by
8
Answer:
CLS
INPUT N
IF N MOD 10 =5 THEN
PRINT "YES, LAST DIGIT IS 5"
ELSE
PRINT "LAST DIGIT IS NOT 5"
END
Logic:-
- Accept a number n
- check if last digit is 5 by using MOD
- YES? Print Yes
- else Print No
Note:-
- MOD stands for modulus used to get remainder.
Similar questions