Skip to main content

Posts

Showing posts from January, 2024

C++ for Loop

  C++ for Loop In computer programming, loops are used to repeat a block of code. For example, let's say we want to show a message 100 times. Then instead of writing the print statement 100 times, we can use a loop. That was just a simple example; we can achieve much more efficiency and sophistication in our programs by making effective use of loops. There are 3 types of loops in C++. for  loop while  loop do...while  loop This tutorial focuses on C++  for  loop. We will learn about the other type of loops in the upcoming tutorials. C++ for loop The syntax of for-loop is: for (initialization; condition; update) { // body of-loop } Here, initialization  - initializes variables and is executed only once condition  - if  true , the body of  for  loop is executed if  false , the for loop is terminated update  - updates the value of initialized variables and ag...