C++ Exercises: Find the nth digit of number 1 to n
15. Find the nth Digit in the Infinite Sequence
Write a C++ program to find the nth digit of the number 1 to n?
Infinite integer sequence: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 .. where n is a positive integer.
Input: 7
Output: 7
Input: 12
Output: 1
The 12th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is 1, which is part of the number 11.
Sample Solution:
C++ Code :
Sample Output:
7th digit of the infinite integer sequence is 7 13th digit of the infinite integer sequence is 1
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C++ program to compute the nth digit in the concatenated sequence of all natural numbers by calculating digit positions.
- Write a C++ program that reads n and finds the corresponding digit in the infinite sequence by iterating through number lengths.
- Write a C++ program to implement an algorithm that determines the nth digit of the sequence without constructing the entire sequence.
- Write a C++ program that uses mathematical formulas to compute the nth digit in the concatenated natural numbers and then prints it.
C++ Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a C++ programming to get the maximum product from a given integer after breaking the integer into the sum of at least two positive integers.
Next: Write a C++ program to find the square root of a number using Babylonian method.
What is the difficulty level of this exercise?