diff options
| author | Tyler Taormina <[email protected]> | 2021-11-09 22:36:26 -0800 |
|---|---|---|
| committer | Tyler Taormina <[email protected]> | 2021-11-09 22:36:26 -0800 |
| commit | f86fe8059b8ae06b748c0e20a80e45a98c2d19d1 (patch) | |
| tree | fa445ca0b5bfbfcd45c64183c2decf661b159682 /mod11b.cpp | |
| parent | November 3, 2021 update to Lab 6. (diff) | |
| download | archived-cst116-lab6-till-t-f86fe8059b8ae06b748c0e20a80e45a98c2d19d1.tar.xz archived-cst116-lab6-till-t-f86fe8059b8ae06b748c0e20a80e45a98c2d19d1.zip | |
Completed modules 11a and 11b.
Need last module.
Diffstat (limited to 'mod11b.cpp')
| -rw-r--r-- | mod11b.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/mod11b.cpp b/mod11b.cpp new file mode 100644 index 0000000..8607ebd --- /dev/null +++ b/mod11b.cpp @@ -0,0 +1,101 @@ +// Tyler Taormina +// CST 116 +// Module 11B Debugging Exercise +// pg 289-292 +// #1 for 10pts + + +#include <iostream> +#include <iomanip> +using std::cin; +using std::cout; +using std::endl; +using std::setw; + +void GetAndDisplayWelcomeInfo ( ); +void FunctionOne ( int varX[], int varY[] ); +void FunctionTwo ( int varX[], const int varY[], int varZ[] ); +void PrintFunction ( const int varX[], const int varY[], + const int varZ[] ); + +const int SIZE = 10; + +int main ( ) +{ + int varX[SIZE]; + int varY[SIZE]; + int varZ[SIZE]; // Notice how we used the const here! + +// Breakpoint 1 + // Put breakpoint on the following line + GetAndDisplayWelcomeInfo ( ); + FunctionOne ( varX, varY ); + + // Breakpoint 3 + // Put breakpoint on the following line + FunctionTwo ( varX, varY, varZ ); + varZ[0] = -99; + PrintFunction ( varX, varY, varZ ); + + return 0; +} + + +void GetAndDisplayWelcomeInfo ( ) +{ + char name[2][20]; // First name in row 0, last name in row 1 + + cout << "Please enter your first name: "; + cin >> name[0]; + + cout << "\nPlease enter your last name: "; + cin >> name[1]; + + // Breakpoint 2 + // Put breakpoint on the following line + cout << "\n\n\tWelcome " << name[0] << " " << name[1] + << "!\n\t Hope all is well \n\n"; +} + + +void FunctionOne ( int varX[], int varY[] ) +{ + for ( int x = 0; x < SIZE; x++ ) // NOTICE '<' NOT <= + // Breakpoint 4 + // Put breakpoint on the following line + varX[x] = x; + + for ( int x = 0; x < SIZE; x++ ) + varY[x] = x + 100; +} + + +void FunctionTwo (int varX[], const int varY[], int varZ[] ) +{ + for ( int x = 0; x < SIZE; x++ ) // Notice the const SIZE here + varZ[x] = varX[x] + varY[x]; + varX[1] = 99; +} + + +void PrintFunction ( const int varX[20], const int varY[20], + const int varZ[20] ) +{ + int x; + + cout << " \t x \t y \t z\n\n"; + + for ( x = 0; x < SIZE; x++ ) + cout << "\t" << setw ( 3 ) << varX[x] + << "\t " << varY[x] + << "\t " << varZ[x] << endl; +} + + + + + + + + + |