Introduction of Loop: we first understood that why we need the loop.
When we create a simple to print the hello on our consol.
Void main()
{
printf(“hello”);
}
in our consol it print only one time : hello.
but our teacher tell us to print the hello in 5 time , than we weite 5 time hello like :
void main()
{
printf(“hello”);
printf(“hello”);
printf(“hello”);
printf(“hello”);
printf(“hello”);
}
so, this is the 5 time to print hello but, it is the time consuming and our program is so long if user want to print 100 time than ot difficulties to write the code.
So, reduce the this difficulties we used the LOOP the loop is so usefull to the user to consistent the time if the the user want to repeateded time than he can used the loop.
There are three type of loop that we can used in our progrm.
1) do while loop.
2) while loop.
3)f or loop.
In first we write the progrm we first learn three condition of the loop.
1) assisgn the value.
2) Condition.
3) Increment or decrement.
All the condition exist in the program if the condition are not exist in the program than it goting to the infinite loop means it never stop.
❮ Previous Next ❯
0 Comments