The for loop
The "for loop" loops starting with one number then onto the next number and increments by a predetermined value each time.
syntax
for (Start value; end condition; increase value)
statement(s);
example
syntax
for (Start value; end condition; increase value)
statement(s);
example
#include<iostream> using namespace std; int main() { int a; for (a= 0; a < 10; a++) { cout << "for loop in c++" << "\n"; cout << "is very easy" << "\n"; } return 0; }
Note that:
a solitary direction can be set behind the "for loop" without the wavy sections.
How about we take a gander at the "for loop" from the illustration: We initially begin by setting the variable a to 0. This is the place we begin to tally. At that point, we say that the for loop must run if the counter m is littler than ten. Last we say that each loop a should be expanded by one (a++).
0 comments:
Post a Comment