VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-to-print-all-three-digit-numbers-in-ascending-order/

⇱ Program to print all three digit numbers in ascending order - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to print all three digit numbers in ascending order

Last Updated : 10 Feb, 2024

Write a program to print all the three-digit numbers in ascending order.

:

100 101 102...till 999

Approach: Using for Loop to print all the three Digit Numbers:

Use for loop to iterate from the smallest three-digit number, that is 100 till we reach the largest three-digit number, that is 999 and, in every iteration, print the number. After reaching 999, we will have all the three-digit numbers in ascending order.

Step-by-step algorithm:

  • Initialize a counter to the smallest 3-digit number i.e. 100.
  • Run a for loop till the greatest 3-digit number i.e. 999.
  • For each iteration print the number

Below is the implementation of the above approach:


Output
All three digit numbers in ascending order: 
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138...

Time Complexity: O(1000) = O(1)
Auxiliary Space: O(1)

Comment
Article Tags:
Article Tags: