Question

Write a program that inputs a number between 1 and 10 and displays the number with...

Write a program that inputs a number between 1 and 10 and displays the number with the appropriate two-letter ending (e.g., 1st, 2nd, 3rd, 4th, 5th, . . . ). Using Visual Logic

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello Reader,

The question is to display the number with it's subscript, for this we must note that from one to 10 - only 1 , 2 , 3 have different subscript else all have same subscript 'th'.

We approach the question by taking the input as 'i' then for safety we assign a new variable t=i, and then checking starts:

if i=1, then (t-1) will be 0 so add "st" at the end

else if i=2, then (t-2) will be 0 so add "nd" at the end

else if i=3, then (t-3) will be 0 so add "rd" at the end

now comes the general case if i>3 then (t-3) will not be 0, (t-2) will not be 0, (t-1) will not be 0 -- so add a "th" at the end

The following image depicts the logic explained above:

Hope it helps!! Any queries are welcomed.

Add a comment
Know the answer?
Add Answer to:
Write a program that inputs a number between 1 and 10 and displays the number with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT