diff options
| author | [email protected] <[email protected]> | 2021-11-09 21:42:11 -0800 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2021-11-09 21:42:11 -0800 |
| commit | a1b87695c40a5169330f3fd8b46e9b8067cbcd5f (patch) | |
| tree | 87b4dc57c008d35521fcf7645abd00e18e34c709 /CST116F2021-Lab6/CST116F2021-Lab6.cpp | |
| parent | LAB6 Answers V1 (diff) | |
| download | cst116-lab6-rayyanansari03-a1b87695c40a5169330f3fd8b46e9b8067cbcd5f.tar.xz cst116-lab6-rayyanansari03-a1b87695c40a5169330f3fd8b46e9b8067cbcd5f.zip | |
V2
Diffstat (limited to 'CST116F2021-Lab6/CST116F2021-Lab6.cpp')
| -rw-r--r-- | CST116F2021-Lab6/CST116F2021-Lab6.cpp | 145 |
1 files changed, 70 insertions, 75 deletions
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.cpp b/CST116F2021-Lab6/CST116F2021-Lab6.cpp index 757b51c..2ba330e 100644 --- a/CST116F2021-Lab6/CST116F2021-Lab6.cpp +++ b/CST116F2021-Lab6/CST116F2021-Lab6.cpp @@ -1,83 +1,78 @@ -// LAB6Ansari-V2.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - #include <iostream> -#include <string> #include <iomanip> -using namespace std; -void acceptStringInfo(string array1[10][2]); -void acceptNumInfo(int studentNum[10], int moneyForClub[10], string array1[10][2]); -int main() { - - int x = 2; - - - string clubInfo[10][2]; - int studentNum[10]; - int moneyForClub[10]; - - acceptStringInfo(clubInfo); - acceptNumInfo(studentNum, moneyForClub, clubInfo); - - cout << "CLUB : PRESIDENT : STUDENTS : BUDGET" << endl; - for (int z = 0; z < 10; z++) { - - cout << clubInfo[z][0] << " : " << clubInfo[z][1] << " : " << studentNum[z] << " : " << moneyForClub[0] << endl; - - } - - +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 -void acceptStringInfo(string array1[10][2]) { - - string club; - string clubPresident; - - - + cout << "Please enter your first name: "; + cin >> name[0]; - for (int i = 0; i < 10; i++) { - - - cout << "Enter club name: "; - getline(cin, club); - cout << endl; - array1[i][0] = club; - - cout << "Enter club president name: "; - getline(cin, clubPresident); - cout << endl; - array1[i][1] = clubPresident; - - - } + 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 acceptNumInfo(int studentNum[10], int moneyForClub[10], string array1[10][2]) { - - int members; - - for (int i = 0; i < 10; i++) { - cout << "How many people are in the club " << array1[i][0] << ": "; - cin >> members; - cout << endl; - studentNum[i] = members; - moneyForClub[i] = members * 75; - } - - - +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 < 5; x++) + varY[x] = x + 100; } -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file +void FunctionTwo(int varX[], const int varY[], int varZ[]) +{ + varX[1] = 99; + for (int x = 0; x < SIZE; x++) // Notice the const SIZE here + varZ[x] = varX[x] + varY[x]; + +} +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; +}
\ No newline at end of file |