aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--In-class-extercise_7/In-class-extercise_7/loops.cpp43
-rw-r--r--In-class-extercise_7/In-class-extercise_7/loops.h11
-rw-r--r--In-class-extercise_7/In-class-extercise_7/program.cpp29
3 files changed, 82 insertions, 1 deletions
diff --git a/In-class-extercise_7/In-class-extercise_7/loops.cpp b/In-class-extercise_7/In-class-extercise_7/loops.cpp
index e69de29..3461b31 100644
--- a/In-class-extercise_7/In-class-extercise_7/loops.cpp
+++ b/In-class-extercise_7/In-class-extercise_7/loops.cpp
@@ -0,0 +1,43 @@
+//Raquel Chavez
+// class :cst 116
+//assignment In class Extercise 3
+
+#include <iostream>
+#include "loops.h"
+
+
+
+void ForLoop(size_t n) {
+ int y = 0;
+ for (y; y < 10; y++) {
+ if (y == n+1) break;
+ std::cout << y << " " ;
+
+ }
+
+ std::cout << " " << std::endl;
+}
+
+void WhileLoop(size_t n) {
+ int a = 0;
+ while (a <= n )
+ {
+ std::cout << a << " ";
+ a++;
+ }
+
+ std::cout << " " << std::endl;
+}
+
+void DOWhileLoop(size_t n) {
+ int m =0;
+ do {
+ std::cout << m << " ";
+ m++;
+
+ } while (m < n +1);
+
+
+ std::cout << " " << std::endl;
+
+} \ No newline at end of file
diff --git a/In-class-extercise_7/In-class-extercise_7/loops.h b/In-class-extercise_7/In-class-extercise_7/loops.h
index 6f70f09..51caf8f 100644
--- a/In-class-extercise_7/In-class-extercise_7/loops.h
+++ b/In-class-extercise_7/In-class-extercise_7/loops.h
@@ -1 +1,10 @@
-#pragma once
+#ifndef MY_HEADER_H
+#define MY_HEADER_H
+
+void ForLoop(size_t n);
+
+void WhileLoop(size_t n);
+
+void DOWhileLoop(size_t n);
+
+#endif \ No newline at end of file
diff --git a/In-class-extercise_7/In-class-extercise_7/program.cpp b/In-class-extercise_7/In-class-extercise_7/program.cpp
index e69de29..70266c2 100644
--- a/In-class-extercise_7/In-class-extercise_7/program.cpp
+++ b/In-class-extercise_7/In-class-extercise_7/program.cpp
@@ -0,0 +1,29 @@
+//Raquel Chavez
+// class :cst 116
+//assignment In class Extercise 3
+
+#include <iostream>
+#include "loops.h"
+
+int main() {
+ int i ;
+ std::cout << "Enter a number: "; // << std::endl;
+ std::cin >> i;
+
+ ForLoop(i);
+
+ int b;
+ std::cout << "Enter another number: ";//<< std::endl;
+ std::cin >> b;
+ WhileLoop(b);
+
+
+ std::cout << "Enter another number: ";// << std::endl;
+ int r;
+ std::cin >> r;
+ DOWhileLoop(r);
+
+
+
+ return 0;
+} \ No newline at end of file