Skip to content

Commit

Permalink
Added comments to while.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
nagrat committed Mar 15, 2023
1 parent 2bfcae8 commit 77d7ce4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Loops/while.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ using namespace std;
*/

void while_loop(int max) {
int y = 0;
while (y < max) {
cout << y << " ";
y++;
int y = 0; // define variable to increment and match condition
while (y < max) { // condition when to stop:: when y is less than max, be false - stop
cout << y << " "; // iterate over it and print with a space after the number
y++; // increment by + 1
}
}

int main() {
while_loop(10);

while_loop(10); // calling function, param -> max which will be in the condition of the while loop
return 0;
}

0 comments on commit 77d7ce4

Please sign in to comment.