Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Usage of the for loop  

While Programming  there may be times when a certain set of statements  have to be executed again and again 

When those situations occur then we make use of for loop 

That is all is for loop,  if anyone is thinking that programming is tough and cannot be understood please do remove that misconception. 
Let me tell you the  syntax of the for loop 

For( initialization ; Condition ; increment /decrement) 
So let’s say I was to print my name 5 times. 

So if this is the task first  thing to do is to take a variable. 

So let’s  take a variable  called i ( u can take anything  usually  these programmers  take i,  u can basically take anything  u want). 
Next initialize  this variable  to 0 ( why 0? U will understand later). 

Next I need to do the condition, my condition is that my name must be printed 5 times 

So i=0 and i

Next is my increment,  as I must  go from  1-5 what I do is i++ 

So this completes the loop 


Print (“Atul Bhargav k s”) 

is my syntax and this will print my name 5 times 

This post first appeared on Coding And Blogging, please read the originial post: here

Share the post

Usage of the for loop  


Subscribe to Coding And Blogging

Get updates delivered right to your inbox!

Thank you for your subscription