diff options
| author | [email protected] <[email protected]> | 2021-11-02 22:02:13 -0700 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2021-11-02 22:02:13 -0700 |
| commit | f62c03942c747163d873d5267a47b3b498971e2a (patch) | |
| tree | cc95f3c3c43f8945ff1d651723d88838cecac969 | |
| parent | Answers V2 Lab 5 (diff) | |
| download | cst116-lab5-rayyanansari03-f62c03942c747163d873d5267a47b3b498971e2a.tar.xz cst116-lab5-rayyanansari03-f62c03942c747163d873d5267a47b3b498971e2a.zip | |
LAB5 ANSWERS ANSARI v3
| -rw-r--r-- | LAB5-Ansari-Answers.txt | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/LAB5-Ansari-Answers.txt b/LAB5-Ansari-Answers.txt index 7c58b53..35dbb69 100644 --- a/LAB5-Ansari-Answers.txt +++ b/LAB5-Ansari-Answers.txt @@ -305,6 +305,113 @@ Press any key to close this window . . . ------------------------------------------------------------------------------------------------------------------- +10a +10.7 Learn by Doing Exercises +p 260 +Break into at least 3 files as in 9b. +10 pts #2 +Submit: code & runs + +CODE: + +FILE 1 (Main): + +// CST116F2021-Lab5.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include "Header.h" + + +int main() +{ + //std::cout << "Hello World!\n"; + + char lastName[30]{}; + char firstName[30]{}; + char fullName[60]{}; + + + printResults(lastName, firstName, fullName); + +} + +FILE 2(Function) + +#include "Header.h" + + +void printResults(char lastName[30], char firstName[30], char fullName[60]) { + + cout << "Enter Last name: "; + + cin.getline(lastName, 30); + + cout << endl; + + cout << "Enter first name: "; + + cin.getline(firstName, 30); + + int x = 0; + + while (firstName[x] != '\0') { + + fullName[x] = firstName[x]; + x++; + + + } + + + //cout << x; + + fullName[x] = ','; + x++; + + fullName[x] = ' '; + + x++; + + int y = 0; + + while (lastName[y] != '\0') { + + fullName[x] = lastName[y]; + y++; + x++; + } + + cout << fullName; + + +} + +FILE 3(Header file) + +#include <iostream> +using namespace std; +void printResults(char lastName[30], char firstName[30], char fullName[60]); + + +OUTPUT: + +Enter Last name: Ansari + +Enter first name: Rayyan +Rayyan, Ansari +C:\Users\ansar\source\repos\OIT Brushup\Debug\OIT Brushup.exe (process 2456) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . + +--------------------------------------------------------------------------------------- + +10b +10.8 Exercises +p 273 +Break into at least 3 files as in 9b. +10 pts #7 Write a full program to do this. +Submit: code & runs + |