diff options
| author | Nataliia Brown <[email protected]> | 2024-02-09 23:47:32 -0800 |
|---|---|---|
| committer | Nataliia Brown <[email protected]> | 2024-02-09 23:47:32 -0800 |
| commit | d5c3e3061f27fb7808f95ff6b72d374af99ecbcf (patch) | |
| tree | 5af1ccff5261b8b579fdbf6227fcef7ab9939744 | |
| parent | headers, setup (diff) | |
| download | in-class-exercise-9-natabrown-d5c3e3061f27fb7808f95ff6b72d374af99ecbcf.tar.xz in-class-exercise-9-natabrown-d5c3e3061f27fb7808f95ff6b72d374af99ecbcf.zip | |
with functions
| -rw-r--r-- | In class ex 9/In class ex 9/ReferenceExamples.cpp | 19 | ||||
| -rw-r--r-- | In class ex 9/In class ex 9/ReferenceExamples.h | 4 | ||||
| -rw-r--r-- | In class ex 9/In class ex 9/program.cpp | 23 |
3 files changed, 43 insertions, 3 deletions
diff --git a/In class ex 9/In class ex 9/ReferenceExamples.cpp b/In class ex 9/In class ex 9/ReferenceExamples.cpp index 83d0de5..c7b540b 100644 --- a/In class ex 9/In class ex 9/ReferenceExamples.cpp +++ b/In class ex 9/In class ex 9/ReferenceExamples.cpp @@ -3,4 +3,21 @@ // Class: CST 116 // Assignment: In-Class Exercise 9 -#include "ReferenceExamples.h"
\ No newline at end of file +#include "ReferenceExamples.h" + +void Swap(int& x, int& y) { + int z = x; + x = y; + y = z; +} + +void Standardize_101(int& n) { + + n = n % 101; + +} + +void Square(int& x) { + + x = x * x; +}
\ No newline at end of file diff --git a/In class ex 9/In class ex 9/ReferenceExamples.h b/In class ex 9/In class ex 9/ReferenceExamples.h index 119938d..eb6a598 100644 --- a/In class ex 9/In class ex 9/ReferenceExamples.h +++ b/In class ex 9/In class ex 9/ReferenceExamples.h @@ -1,9 +1,11 @@ #ifndef REFERENCE_EXAMPLES_H #define REFERENCE_EXAMPLES_H +void Swap(int& x, int& y); +void Standardize_101(int& n); - +void Square(int& x); #endif diff --git a/In class ex 9/In class ex 9/program.cpp b/In class ex 9/In class ex 9/program.cpp index 1a86318..df2691d 100644 --- a/In class ex 9/In class ex 9/program.cpp +++ b/In class ex 9/In class ex 9/program.cpp @@ -4,7 +4,28 @@ // Assignment: In-Class Exercise 9 #include <iostream> +#include "ReferenceExamples.h" using std::cout; using std::cin; -using std::endl;
\ No newline at end of file +using std::endl; + +int main(){ + int x = 5, y = 72; + + Swap(x, y); + + cout << "x = " << x << ", y = " << y; + + int n = 4392; + + Standardize_101(n); + + cout << "Modded n = " << n << endl; + + Square(n); + + cout << "Squared n = " << n << endl; + +} + |