From 77d7ce4bdffb93353d0e51be3407cc9ba0d0b130 Mon Sep 17 00:00:00 2001 From: nagrat Date: Wed, 15 Mar 2023 19:16:10 +0000 Subject: [PATCH] Added comments to while.cpp --- Loops/while.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Loops/while.cpp b/Loops/while.cpp index b234ce8..34c69b5 100644 --- a/Loops/while.cpp +++ b/Loops/while.cpp @@ -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; } \ No newline at end of file