So, what are Loops? Basically, Loops are used for repeating the same codes multiple times, i.e. executing same codes multiples. Let's learn it with the help of an example. Suppose you need to print Hello 15 times on the screen. The Simple way is to write printf function 15 times with the "Hello". So it will print Hello 15 times. But what if you want to print Hello 1000 or infinite times, then at that time, Loops are used. There are 2 types of Loops :- </1> Entry Controlled Loop Entry Controlled Loop means first the condition is checked, if satisfies then it executes the block of codes. # for Loop # while Loop </2> Exit Controlled Loop Exit Controlled Loop means the block of code inside the loop is executed first and then the condition is checked. # do ... while Loop
Next
« Prev Post
« Prev Post
Previous
Next Post »
Next Post »
Subscribe to:
Post Comments (Atom)
0 Comment