Print 1 to 100 numbers in cpp is very simple and easy program to implement.
In this tutorial we are going to learn program which is Print alphabets 1 to 100.
Topic you need to know for this program is :
looping in c – for loop , while , do while loop
basic input output
logic to print 1 to 100 numbers in cpp
Using for loop we initialize start value to start = 1 and as we want number till end we write a condition start <= 100 so that loop will iterate 100 times and at each iteration we increment by 1 i.e. start ++. And in block of loop we print value of start so that we get numbers 1, 2 … 100
Algorithm to print 1 to 100 numbers in cpp
- Start
- Initialize variable i=1
- Write for loop with condition i <= 100
- If condition true then print value of i
- If condition get false skip loop
- End
As above we seen how to print 1 to 100 numbers and it’s algorithm so let’s move to program to implement this.
Program to print 1 to 100 numbers in cpp
123456789101112131415161718192021 | #include <iostream>using namespace std;int main(){ int i; //main logic for(i=1;i<=100;i++){cout<<” “<<i; } return 0;} |
Output :-

Explanation :-
1. First line we include the preprocessor directives in our program
2. Start with main function where program execution starts.
3. Declare variable
i => to hold numbers from 1 to 100
4. Next write for loop
for (i = 1 ; i <= 100 ; i ++)
At first iteration
i is initialized to 1 so that i= 1 , next condition is checked i <= 100 i.e. 1 <= 100. The condition become true and for block get executed
cout<<” “<<i; => 1 get printed
After block execution i is incremented by 1
At second iteration
i = 2 , next condition is checked 2 <= 100 which becomes true and loop block get executed.
cout<<” “<<i; => 2 get printed
After block execution i is incremented by 1
5. This will continue till value of i = 101.
While i = 101 condition 101 <= 100 which becomes false and execution come out of the loop.
6.Finally we the numbers from 1 to 100 printed on screen.