Read a positive integer input n and count the number of


Question: Read a positive integer input n, and count the number of occurrences of the digit '9' in the decimal representation of all the numbers between 1 and n inclusive. Print that number.

For instance:

Number? 19

2

Maybe the easiest way to do this is to convert each number from 1 to n to a string, and then count the number of "9" characters in that string.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Read a positive integer input n and count the number of
Reference No:- TGS0952703

Expected delivery within 24 Hours