Skip to content
Permalink
Browse files
Added comments to while.cpp
  • Loading branch information
nagrat committed Mar 15, 2023
1 parent 2bfcae8 commit 77d7ce4bdffb93353d0e51be3407cc9ba0d0b130
Showing 1 changed file with 5 additions and 6 deletions.
@@ -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.