Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
There are 15 Questions for a total of 100 points.
Answer ALL the questions
NAME: MUID:
General Instructions
?First, ensure you have all the 10 pages of this exam booklet even before starting
?This exam is closed notes and closed books. No discussions are permitted
?You may use Calculator
?Do not bring out your cell phone; don’t answer the phone; don’t read text messages
?You have 2 hours to complete the exam
?Write your answers clearly
?The size of the space given for each answer is sufficient
?Write no more than 3-4 lines for each of the short questions
?Show all your works for the Mathematical problems
?Even if your final answers are incorrect, you will get partial credit if intermediate steps are clearly shown to highlight thought process. This applies to program tracing questions as well.
Good Luck!
SHORT QUESTIONS.
[5 * 10 = 50 point]
1.Briefly (1 to 2 sentences each) state the 4 key principles of object-oriented programming
2.Elaborate the meaning of the following as well as mention the port number that they use:
ProtocolElaborated meaningPort Number
SMTP
3.For a communication session between a pair of processes, which process is the client and which is the server?
4.What information is used by a process running on one host to identify a process running on another host?
5.What is the difference between unordered_map and vector?
6.What do you understand by the term CSV? Consider the following contents of a file, faculty.txt:
054, Campbell
103, Kiper
112, Rao
a.What UNIX/Linux command can be used to produce a output, list just the faculty names:
Campbell
b.What C++ function/code that can be used to produce the similar output for the above. Make necessary assumptions.
7.How is a well-known port different from an ephemeral port?
8.A user on the host 170.210.17.145 is using a Web browser to visit www.example.com. In order to resolve the www.example.com domain to an IP address, a query is sent to an authoritative name server for the “example.com” domain. In response, the name server returns a list of four IP addresses in the following order {192.168.0.1, 128.0.0.1, 200.47.57.1, 170.210.17.130}. Even though it is the last address in the list returned by the name server, the Web browser creates a connection to 170.210.17.130. Why?
9.A Host has an IP address of 10001000 11100101 11001001 00010000. Find the class and decimal equivalence of the IP address.
10.Draw a TCP/IP Internet that consists of two networks connected by a router. Show a computer attached to each network. Show the protocol stack used on the computers and the stack used on the router
C++ Coding Problems
11. [10] Develop a simple C++ program that:
a. Reads words (separated by whitespace only and not any other punctuation or special characters) from the user until logical end-of-file
b. Prints the just the count of words (just one integer and no other text/messages) that start with an English vowel, i.e., one of: AEIOUaeiou characters.
For example, given just the sentence “Elephants are Awesome animals” the output will be 4. Similarly, for the input “I think I am warming up to C++” the output is also 4.
12.[5] Assume that a system has a 32-bit virtual address with a 4-KB ( 1 KB = 1024) page size. Write a C++ program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows:
./a.out 19986
Your program would output:
The address 19986 contains:
page number = 4
offset = 3602
13.[10] Complete the following method that returns a vector with only odd values in the src vector. If the src vector has values {2, -4, 7, 9, 3, 8} this method should return a vector with values {7, 9, 3}.
using IntVec = std::vector<int>;
IntVec odds(const IntVec& src) {}
14.[10] File I/O using file streams
Develop a C++ program that prints the first line of each paragraph in a given text file specified as command-line argument. Paragraphs are separated by one or more blank (i.e., empty) lines.
a. In order gain practice working with generic I/O streams, add the following method that works with abstract streams to your starter code:
void printFirstLine(std::istream& is, std::ostream& os)
The above method is the one that should process lines from input stream is (use std::getline to read lines) and print first line of each paragraph to output stream os.
b. Call the printFirstLine method (from main) with a suitable std::ifstream to process data from a given text file specified as a command-line argument. Recollect that the file name will be in argv[1] in the main method. Use std::cout as the output stream.