Posts

Showing posts with the label what is loop in c

While Loop in C++ Programming Language

Image
  While Loop in C++ Programming Language We have discussed about the entry-controlled loop or pre-tested loop previously in our blog posts. These statements or loops are used to repeat a piece of code for a specific number of times as per our program requirement. We have studied about the for loop already. Today in this blog post we are going to study about the while loop in C++ programming language. And we will look at how this while loop actually works and how we can stop it by making some condition false so that the loop might not run infinitely. We use while loop in C++ program when the number of iterations is not known in advance and depends on the condition. When we know exactly that how many times a loop should run then we use the for loop instead of while loop. Basic Syntax Of While Loop in C++ Programming Language Basic Working Of While Loop In C++ Programming Language Now we are going to discuss about the basic working of while loop in C++ programming....

for loop in C programming language for beginners

Image
  for loop in C programming language for beginners In programming languages, we have control statements that are used to control the behavior of the programs as per user requirements. One of these control statements is in a for loop that we use to iterate the piece of code several times as per user requirement or the programmer's logic. The most common use of a for loop is traversing data structures from beginning to end. One such example of data structures is the arrays and linked lists. Basically, we use a for loop in the conditions when we are sure about the exact number of times the block of code is to be iterated. In such situations, it is preferred to use the for loop. Syntax of for loop in c: for(expression1; expression2; expression3) { // block of code to be executed here } Now if we look at the syntax of the for loop it contains for keyword and round brackets in which there are three expressions given which are separated by a semicolon (;) symbol....