From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp | 67 +++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp (limited to 'C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp') diff --git a/C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp b/C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp new file mode 100644 index 0000000..d6bc9aa --- /dev/null +++ b/C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp @@ -0,0 +1,67 @@ +// Name: msglm +// Date: +// Program Name: +// Description: + + +#include +#include +#include +using namespace std; + +// Named constants + +int main() { + + //Variable declaration + int i; + int score; + int choice; + + // Example 1 + cout << "Do While Loop Example 1" << endl; + + i = 11; + + do { + cout << i << " " << endl; + i = i + 5; + } while( i <= 30 ); + + cout << "Out of the Loop!" << endl << endl; + + //Example 2 + + cout << "Do While Loop Example 2" << endl; + + do { + cout << "Enter a score between 0 and 50" << endl; + cin >> score; + cout << endl; + + if(score < 0 || score > 50) { + cout << "It is an invalid input" << endl; + } + } while (score < 0 || score > 50); + cout << "That was a valid input" << endl; + + cout << "Do While Loop Example 3" << endl; + + cout << "Menu Options" << endl << endl; + cout << "1 - Option 1" << endl; + cout << "2 - Option 2" << endl; + cout << "3 - Option 3" << endl; + + do { + cout << "Enter your choice:" << endl; + cin >> choice; + } while(choice<1||choice>3); + cout << "Your choice is: " << choice << endl; +} + +/*This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see . + */ + -- cgit v1.2.3