1. the output of the code bellow will be:
char str1  =”engineer”;
char str2  =” “;
strncpy (str2, &str1,3);
B. b. “engin”
C. c. “gineer”
D. D. “ngi”
2. If you attempt to open a non -existing file for output.
A. It is automatically created if it’s a text file
B. It is automatically crated if it’s a binary file.
C. The open failts
D .a) and b) statemeenets are correct.
E. A) and B) statements are incorrect
3. If you open an existing file for input,
A. The file size is changed to zero if it’s a binary file
B. The file size is changed to zero if it’s a text file.
C. The file size remains unchanged
D. The file is truncated.
E. The file is renamed.
4. If you open a non-existing file for input,
A. It is automatically created if it’s a text file.
B. It is automatically created if it’s binary file.
C. The open failts
D. EIther the file is automatically created or the open fails depending upon the compiler configuration.
5. If you write 10 integers (int) to an empty binary file.
A. The file will contain a total of 10 * sizeof (int) bytes if it’s a text file
B. The file will contain a total of 10 * sizeof (int) bytes if it’s a binary file.
C. A and B statements are correct
6. Which one of the following statements is correct
A. function read is used to read from a text file.
B. operator >> is used to read from a text file.
C. function getline is used to read from a ttext file.
D. A and B statements are correct.
E. A and B sgtatements are incorrect.
7. Which of the following statements is correct.
A. function write is use to write to a binary file.
B. function seekp is ued to move to a new write position in a binary file.
C. function tellp is sued to enquire the current write position in a binary file.
D. B and C statement are correct.
8. If fobj is a object of type fstream, then the follwing statement
A. sets the write position to the 33rd byte ( byte 32) from the beginning
B. sets the write position to the 32rd byte ( byte 31) from the beginning of the file
C. it works differently with different operating systems
D. you cannot tell from the information given
9) if fobj is a object of type fstream, then the following statement
A. sets the write pos to the 119st byte ( byte 118) from the current postion.
B. sets the write pos to the 121st byte ( byte 120) from the current position.
C. it works differently with different operating systems.
D. you cannot tell from the information given.
10) Consider the following code:
fstream fout(“data.dat”, ios::out|ios::binary);
char c = ‘A’;
fout.write(&c, size of (c));
11) Consider the follow. The file “letters.dat” contains ABCDEFGHIJ
fstream fin(“letters.dat”, ios::in|ios::binary);
What willbe the output?
12) Consider the following two pieces of code:
First pieceof code:
of stream outClientFile(“clients.dat”, ios:out);
Second piece of code:
of stream outClientFile;
A. The first piece will successfuly open the “clients.dat” for output but the second will not.
B. The second piece will successfuly open the “clients.dat” for output but the first will not
C. Both pieces of tcode will not be able to successfuly open the file because it is not specified if the file is binary or not.
D. Both pieces of code are perfectly correct and will open the file for output
13) Member function tell g and tell p are provided to return the current locations of the get and put pointers, respectively.
14) Assume clientData is a structure type previously defined and client is a variable of that type. The function
inCredit.read ( reinterpret_cast(&client), size of (clientData));
inputs a specified (by size of ( clientData)) number of bytes from the current position of the speciifed stream into client.
15) The member function write outputs a fixed nubmer of bytes beginning at a specfic location in memory to the specific stream. When the stream is associated with a file, the adata is written beginning at the location in the file specified by the “put” file pointer.
16) and classes provide member functions for repositioning the file pointer ( the byte nubmer of the next byte in the file to be read or to be written.)
These member functions are:
A. seekp (seek put) for istream class seekg (seek get) for ostream class
B. Seekg (seek get) for istream class seekp ( seek put) for ostream class
C. Functions like these do not work with and classes but work only with class
17). Which of the following is linked list node?
A. struct ListNode
LnkedList * next;
B. struct ListNode
C. struct ListNode
D. struct List Node
18) Recursion can be sued to display the linkeed list backward but won’t work for displaying it forward.
19) Inserting a new value in the middle of a singly lnked list requires changing the pinter of the list node that follows the new node.
20) Deleting a node in the middle of a singly lnked list requires changing the pointer of the list node that precedes the node being deleted.
21) (*x).y and *x.y are equivalent.
22) (*x).y and *x->y are equivalent.
23) (*x).(*y).z and *x->y->z are equivalent.
24) If the following fjunction is caleld wit ha value of 2 for n, what is the resulting output?
Void Quiz (int n)
if (n > 0)