Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Документ.rtf
Скачиваний:
8
Добавлен:
25.02.2016
Размер:
140.88 Кб
Скачать

Preparation for Final Exam mcq Quiz big - Попытка 1

Страница:  (HYPERLINK "javascript:navigate(8);"НазадHYPERLINK "javascript:navigate(8);")  1  2  3  4  5  6  7  8  9  10 

Question91

Баллов: 1

What should you do to free the memory after running this code?

char *a; a = new char[20];

Выберите один ответ.

a. I don't know

b. delete a;

c. delete [] a;

d. delete a[];

e. no of these

Question92

Баллов: 1

All variables must be given a type when they are declared.

Ответ:

TrueFalse

Question93

Баллов: 1

Write one or more statements that perform the following task for and array called “fractions”. Print all the array elements using a for statement. Define the integer variable i as a control variable for the loop. 

Выберите один ответ.

a. for ( i = 0; < arraySize; i++ ) cout << "fractions[" < i << "] = " << fractions[ i ] << endl;

b. for ( int i = 0; < arraySize; i++ ) cout << "fractions[" < arraySize << "] = " << fractions[arraySize ] << endl;

c. no ideas

d. for ( int i = 0; < arraySize; i++ ) cout << "fractions[" < i << "] = " << fractions[ i ] << endl;

Question94

Баллов: 1

Storage-class specifier  is a recommendation to the compiler to store a variable in one of the computer's registers.

Question95

Баллов: 1

In C++, it is possible to have various functions with the same name that operate on different types or numbers of arguments. This is called function ________.

Выберите один ответ.

a. prototype

b. copy

c. duplicate

d. overloading

e. not sure

Question96

Баллов: 1

What is the output of the program?

#include<iostream>

usingnamespace std;

int main() {

 char str[] = "de_dust";

 for (int i=strlen(str)-1; i>=0; i--)

 cout << str[i];

 cout << endl;

 return 0;

}

Выберите один ответ.

a. sud_e

b. sud_ed

c. de_dust

d. tsud_ed

e. tsud_e

Question97

Баллов: 1

Which of the following accesses a variable in structure b?

Выберите один ответ.

a. b-var;

b. b->var;

c. b>var;

d. b.var;

e. b>>var

Question98

Баллов: 1

If n=3, what will be the result of:

switch{case '3':cout << "wow \n";break;case 3:cout << "bab \n";break;default:cout << "heh \n";break;}

Выберите один ответ.

a. Compiler error

b. heh

c. wow

d. Undefined behaviour

e. bab

Question99

Баллов: 1

Assuming that nPtr points to the beginning of array numbers (the starting address of the array is at location 1002500 in memory), what address is referenced by nPtr + 8?

Выберите один ответ.

a. The same as nPtr

b. NULL

c. The address is 1002500 + 8 * 8 = 1002564

Question100

Баллов: 1

Find the error(s) in the following code segment: switch ( n ) { 

case 1: 

cout << "The number is 1" << endl; 

case 2: 

cout << "The number is 2" << endl; break; 

default: 

cout << "The number is not 1 or 2" << endl; break; 

}

Выберите один ответ.

a. switch ( n ) { 

case 1: 

cout << "The number is 1" << endl; break; 

case 2: 

cout << "The number is 2" << endl; break; 

}

b. switch ( n ) { 

case 1: 

cout << "The number is 1" << endl; break; 

case 2: 

cout << "The number is 2" << endl; break; 

default: 

cout << "The number is not 1 or 2" << endl; break; 

}

c. switch ( n ) { 

case 1: 

cout << "The number is 1" << endl; 

case 2: 

cout << "The number is 2" << endl; 

default: 

cout << "The number is not 1 or 2" << endl; 

}