Howdy readers, today you will learn how to write a C++ program to print 1 to 100.
This tutorial will print integers from 1 to 100 using the following methods:
- Using For Loop
- Using While Loop
- Using Do While Loop
So, without any delay, let’s begin this tutorial.
C++ Program to Print 1 to 100 Using For Loop
C++ Program
// C++ Program to Print 1 to 100 #include <iostream> using namespace std; int main(){ int num; for (num = 1; num <= 100; num++){ cout << num << " "; } return 0; }
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Explanation
for (num = 1; num <= 100; num++){ cout << num << " "; }
In this program, we have used a for loop to iterate integers from 1 to 100. Within the loop, we print the integer and increase the value of num
by 1.
This process keeps on executing until num <= 100
.
C++ Program to Print 1 to 100 Using While Loop
C++ Program
// C++ Program to Print 1 to 100 Using While Loop #include <iostream> using namespace std; int main(){ int num = 1; while (num <= 100){ cout << num << " "; num++; } return 0; }
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

C++ Program to Print 1 to 100 Using Do While Loop
C++ Program
// C++ Program to Print Numbers From 1 to 100 Using Do While Loop #include <iostream> using namespace std; int main(){ int num = 1; do { cout << num << " "; num = num + 1; } while (num <= 100); return 0; }
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

Conclusion
Today you learned how to write a C++ program to print 1 to 100.
If you have any questions related to the tutorial, comment down your queries in the comment section.
Thanks for reading.
Happy Coding!!
Also Read:
- C++ Program to Print Even Numbers
- C++ Program to Print Even Numbers From 1 to 100
- C++ Program to Print Odd Numbers From 1 to 100
- C++ Program to Convert Fahrenheit to Celsius
- C++ Program to Multiply Two Numbers Using Function