Posts

Showing posts from September, 2020

Loops in C++

Image
First of all i want to show you the book by which iam now a pro in c++ .You can buy it by clicking here C++ book  Loops Loops are used to repeat a block of code.This also helps you by saving your time ,reducing errors and making code readable.There are 3 loops in c++ . For loop A for loop enables a particular set of conditions to be executed repeatedly until a condition is satisfied Example # include <iostream> using namespace std; int main(){    int i=1; while(i<=6) {       cout<<"Value of variable i is: "<<i<<endl; i--;    } } While Loop In While loop we give a condition and the loop continues until the condition becomes false.  Example  int pro = 0;  while ( pro < 5) {  cout << pro << "\n";  pro++;  }  In the above example (i<5) is a condition and the loop will continue until it becomes false Do While loop   This loop is also like while loop but it executes...