Computer Science, asked by surjyoprprovomotilal, 26 days ago

input of a number and print whether the last digit is 5 or not​

Answers

Answered by anindyaadhikari13
8

\textsf{\large{\underline{Solution}:}}

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

\textsf{\large{\underline{Explanation}:}}

  1. Line 1: Clears the screen.
  2. Line 2: Accept the number from the user.
  3. Line 3: Calculate the last digit of the number entered.
  4. Line 4: Check if last digit is 5 or not.
  5. Line 5: If true, last digit is 5. Print a message.
  6. Line 6: Else part.
  7. Line 7: When condition is false, last digit is not 5.
  8. Line 8: End of if-else.
  9. Line 9: End of program.

See the attachment for output.

Attachments:

anindyaadhikari13: Thanks for the brainliest :)
Answered by BrainlyProgrammer
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