Question 54
What (if anything) prints when the following statement is performed?Assume the following variable declarations:
char s1[ 50 ] = "jack";
char s2[ 50 ] = "jill";
char s3[ 50 ];
cout << strlen(s1) + strlen(s2) << endl;
Question 55
Which functions will every class contain?
c. Both a constructor and a destructor |
Question 56
Find the error(s) in the following and correct it (them).
Assume the following prototype is declared in class Employee:
int Employee(const char *, const char *);
Employee(const char *, const char *);
Question 57
What will be the result after running this code:
for(int i=0;i<3;i++)
{
cout << i << " ";
continue;
cout << 7 << " ";
break;
for(int j=0;j<1;j++)
cout << 5 << " ";
}
B. 0 1 2
Question 58
Find the error in the following program segment. Assume the following declarations and statements:
int *zPtr; // zPtr will reference array z
int *aPtr = 0;
void *sPtr = 0;
int number;
int z[ 5 ] = { 1, 2, 3, 4, 5 };
if (strcmp(string1, string2))
cout << "The strings are equal" << endl;
b. if (strcmp(string1, string2) == 0)
cout << "The strings are equal" << endl;
Question 59
The four objects that correspond to the standard devices on the system include _________, _________, __________ and ___________.
Cin, cout, cerr and clog
Question 60
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Assign the value of the object pointed to by fPtr to variable number2.
|
|
. number2 = *fPtr;
Question 61
What value does foo print out?
#include <iostream>
const int SIZE = 5;
struct tester
{
void foo()
{
std::cout << SIZE << std::endl;
}
enum
{
SIZE = 3
};
};
int main(int argc, char** argv)
{
tester t;
t.foo();
return 0;
}
. 3
Question 62
Select the best answer to the output of the program:
#include<iostream>
usingnamespace std;
int main() {
double y = 10;
double *x = &y;
cout << x << " " << x-1 << " " << *x-1 << endl;
return 0;
}
e. None of the given choices. |
Question 63
Outputs to the standard error stream are directed to either the ___________ or the ___________ stream object