Skip to content
Permalink
Browse files
Added contents to do_while.cpp
  • Loading branch information
nagrat committed Mar 15, 2023
1 parent 77d7ce4 commit 65c4a72189268589d2a65e41216c1319e643610f
Showing 1 changed file with 21 additions and 0 deletions.
@@ -0,0 +1,21 @@
#include <iostream>

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;
}

0 comments on commit 65c4a72

Please sign in to comment.