summaryrefslogtreecommitdiff
path: root/while.cpp
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-07-28 12:52:38 +0200
committerOskar <[email protected]>2024-07-28 12:52:38 +0200
commit5aac3c3f8bcfef0b2aad28d91d87b9ebf1d5e7df (patch)
tree38736b9f0c57f69e272121e0fc1f3969bb7468e2 /while.cpp
first commit
Diffstat (limited to 'while.cpp')
-rw-r--r--while.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/while.cpp b/while.cpp
new file mode 100644
index 0000000..189d66a
--- /dev/null
+++ b/while.cpp
@@ -0,0 +1,40 @@
+#include <iostream>
+
+/*
+ *
+ * A little bit of while looping
+ *
+ *
+ *
+ *
+ *
+ */
+
+int main (void) {
+
+ int val = 1;
+ int val2 = 10;
+ while(val <= 10) {
+ std::cout << val << std::endl;
+ val++;
+ }
+
+ while(val2 >= 1) {
+ std::cout << val2 << std::endl;
+ val2--;
+ }
+
+ std::cout << "Done." << std::endl; // We send text to 'cout' a so called 'ostream'
+ uint64_t sum = 0;
+ uint64_t one = 0;
+ uint64_t two = 0;
+ std::cin >> one >> two;
+ uint64_t original_one = one;
+ while(one <= two) {
+ sum += one;
+ one++;
+ }
+
+ std::cout << "The sum of "<< original_one << " to " << two << " inclusive is: " << sum << std::endl;
+ return 0;
+}