Series of digits by using for loop
Basically a Loop is used to run a set of statements under certain pre-dominated conditions and it runs till the condition is true and eventually stops as the condition becomes false.
There are certain loops defined in the programming languages like While, do-while and for loop but here we gonna discuss about only for-loop.
The syntax for the for-loop is as listed below:
Below is the flow chart for a for-loop that shows how a for loop basically works in step by step manner this will help you to grab more and learn and understand easily.
Basic example of code for generating a series of digits by using for loop is written below
we are taking one initial and final value to generate the series between those two number in our case let say a, b and incrementing it by only a value of one.
If you wish you can change the input values and increment by your needs like by 2 or 5.
Code in C++ :
Sample input :
Enter value of 1st number : 1
Enter value of 1st number : 10
Sample output :
The output series of digits are :
1 2 3 4 5 6 7 8 9 10
Code in C :