// Tyler Taormina // CST 116 // Module 11B Debugging Exercise // pg 289-292 // #1 for 10pts #include #include 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; }