While is one of loop in C++. Loop is used to repeat one or more statement. Syntax of while is similar with if syntax.
Example :
1 2 3 4 5 6 7 8 9 10 finished
Loop will be repeated as long as condition is true.
While is one of loop in C++. Loop is used to repeat one or more statement. Syntax of while is similar with if syntax.
#include <iostream>
using namespace std;
int main(){
int numr=1;
while(numr<=10){
cout << numr << endl;
numr++;
}
cout << "finished";
return 0;
}
1 2 3 4 5 6 7 8 9 10 finished
Loop will be repeated as long as condition is true.