summaryrefslogtreecommitdiffstats
path: root/C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp')
-rw-r--r--C++/DoWhileLoopPractice/DoWhileLoopPractice.cpp67
1 files changed, 67 insertions, 0 deletions
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 <iostream>
+#include <string>
+#include <iomanip>
+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 <https://www.gnu.org/licenses/>.
+ */
+