From 65c4a72189268589d2a65e41216c1319e643610f Mon Sep 17 00:00:00 2001 From: nagrat Date: Wed, 15 Mar 2023 19:20:51 +0000 Subject: [PATCH] Added contents to do_while.cpp --- Loops/do_while.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Loops/do_while.cpp b/Loops/do_while.cpp index e69de29..0985f50 100644 --- a/Loops/do_while.cpp +++ b/Loops/do_while.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +/* + Do while. A while loop with do. + It's literally this ^^^. +*/ + +void do_while_loop(int max) { + int x = 0; // define variable to increment and match condition + do { // commence the code block + cout << x << " "; // iterate over it and print with a space after the number + x++; // increment by + 1 + } while (x < max); // while condition (same as while.cpp) +} + +int main() { + do_while_loop(10); // calling function (you will know what max is by now I'm sure) + return 0; +} \ No newline at end of file