/* */ Click to Join Live Class with Shankar sir Call 9798158723

For loop in C++


A for loop is a control statement using which the programmer can give instructions to the computer to execute a set of statement repeatedly as long as specified condition is satisfied. It is required to specify how many times a set of statements have to be executed, it is also called counter controlled loop.


Syntex :-

for(initialization; condition; increment/decrement){
//statement or code to be executed
}

Q.) W.A.P To Print The square root of a number in C++ ?
    #include < iostream>
#include< math.h>
using namespace std;
int main()
{
  float NO, answer_of_GivenNO;
  cout <<"Enter number to find its squareroot: ";
  cin >> NO;
  answer_of_GivenNO = pow(NO, 0.5);
  cout<<"Squreroor of "<< NO<<" is: " << answer_of_GivenNO << endl;
}
Output
Enter number to find its squareroot: 4
Squreroor of 4 = 2.