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

 

Preparation for Final Exam MCQ Quiz BIG - Попытка 2

Начало формы

Страница:  1  2  3  4  5  6  7  8  9  10  (Далее) 

Question1

Баллов: 1

Where can you put a continue statement?

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

a. In a nested loop

b. I don’t know

c. In or as a loop body

d. Inside a function

e. Everywhere in the program

Question2

Баллов: 1

$$1 What is the output of the program below?

#include<iostream>

usingnamespace std;

int func() {

 return 55;

}

int main() {

 cout << 1+func() << endl;

 return 0;

}

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

a. Undefined

b. 54

c. 55

d. 56

e. Nothing

Question3

Баллов: 1

Find four different C++ statements that each add 1 to integer variable x:

Выберите по крайней мере один ответ:

a. x++;

b. ++x;

c. x == x + 1;

d. x += 1;

e. x = x + 1;

f. x += x + 1;

g. x =+ 1;

Question4

Баллов: 1

What is the output of the program?

#include <iostream> using namespace std; int main() { for (int a=10; a<91; a*=3) cout << a-1 << " "; cout << endl; return 0; }

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

a. 9 29

b. 10 30 90 270

c. 10 30

d. 9 29 89

e. 10 30 90

Question5

Баллов: 1

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. Compare the string in s1 with the string in s2, and print the result.

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

a. cout << "strcmp(s1, s2) = " << strcmp( s1, s2 ) << endl;

b. cout << "strcmp(s1, s2) = " << string_compare( s1, s2 ) << endl;

c. cout << "strcmp(s1, s2) = " << cmpstr( s1, s2 ) << endl;

d. cout << "strcmp(s1, s2) = " << strcompare( s1, s2 ) << endl;

Question6

Баллов: 1

A variable declared outside any block or function is a( n )  variable.

Question7

Баллов: 1

What output will be produced by the following code?

int extra = 0;

if (extra < 0)

cout << "small";

else if (extra == 0)

cout << "medium";

else

cout << "large";

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

a. Error

b. medium

c. None of the given choices.

d. large

e. small

Question8

Баллов: 1

Predecrement the variable x by 1, then subtract it from the variable total

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

a. total -= ++x;

b. total -= --x;

c. total -= x--;

d. total -= x++-;

e. total = --x;

Question9

Баллов: 1

Return type  indicates that a function will perform a task but will not return any information when it completes its task

Question10

Баллов: 1

Input operations are supported by class __________.

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

a. ifile

b. istream

c. sinput

d. fstream

 

 

Preparation for Final Exam MCQ Quiz BIG - Попытка 2

Начало формы

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

Question11

Баллов: 1

Output the address of the variable myString of type char *

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

a. cout << static_cast< void >( myString );

b. cout << static_cast< void * >( myString );

c. cout << void * ( myString );

Question12

Баллов: 1

Identify and correct the errors in the following statement (assume that the statement using std::cout; is used): if ( c < 7 ); 

cout << "c is less than 7\n";

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

a. if ( c < 7 ) then cout << "c is less than 7\n";

b. if ( c < 7 ); { cout << "c is less than 7\n";}

c. if ( c < 7 ) { cout << "c is less than 7\n"}

d. if ( c < 7 ) cout << "c is less than 7\n"

e. if ( c < 7 ) cout << "c is less than 7\n";

Question13

Баллов: 1

The __________ operator dynamically allocates memory for an object of a specified type and returns a __________ to that type.

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

a. correct, reference

b. new, pointer

c. local, name

Question14

Баллов: 1

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 };

char s[ 12 ];

strcpy( s, "Welcome Home");

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

a. no errors

b.  char s[ 13 ]; strcpy( s, "Welcome Home");

c.  char s[ 11 ]; strcpy( s, "Welcome Home");

Question15

Баллов: 1

A __________ should be used to declare the size of an array, because it makes the program more scalable

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

a. constant variable

b. static variable

c. number

d. constant

Question16

Баллов: 1

Find the error(s) in the following code segment:  x = 1;  while ( x <= 10 ); 

x++; 

}

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

a. x = 1;  while ( x <= 10 )  { 

x++

b. x = 1;  while ( x <= 10 ) 

x++;

}

c. x = 1;  while ( x <= 10 ); 

x++; 

{  }

d. x = 1;  while ( x <= 10 );  { 

x++; 

}

Question17

Баллов: 1

Add variable x to variable sum and assign the result to variable sum

Ответ:

Question18

Баллов: 1

A function ________ enables a single function to be defined to perform a task on many different data types

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

a. prototype

b. not sure

c. base function

d. template

e. originator

Question19

Баллов: 1

What will be output? #include <iostream> using namespace std; void function1(int *a){  cout << *(a + 1) << " " << *(a + 9); } int main() { int arr[] = {9,8,7,6,5,4,3,2,1,0};  function1(arr); return 0; }

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

a. 8 0

b. 8 1

c. 9 1

d. 9 2

Question20

Баллов: 1

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 }; ++z;

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

a. ++z[4];

b. ++*z;

c. ++&z;

 

Preparation for Final Exam MCQ Quiz BIG - Попытка 2

Начало формы

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

Question21

Баллов: 1

How can you ensure that an inline function isn't inlined for a particular function call for function foo?

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

a. noexpand x();

b. unline x();

c. This is not possible on a case-by-case basis

d. x();

e. static x();

Question22

Баллов: 1

Which of the following shows the correct syntax for an if statement?

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

a. if{ expression

b. if [expression]

c. expression if

d. if expression

e. if( expression)

Question23

Баллов: 1

Set variable sum to 0

Ответ:

Question24

Баллов: 1

Which of the following is a properly defined struct?

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

a. struct a_struct int a;

b. struct a_struct {int a;};

c. struct {int a;}

d. Struct a_struct {int a;};

e. struct a_struct {int a;}

Question25

Баллов: 1

What should get printed in the program below?

#include <iostream> using namespace std;

class foo{ public: foo() : z(x+1), y(2), x(3) { cout << "z: " << z << endl; } private: int x; int y; int z; };

int main(int argc, char** argv){ foo f; return 0; }

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

a. 4

b. 1

c. 3

d. 2

Question26

Баллов: 1

Which of the following operators does NOT indicate a sequence point in the code?

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

a. =

b. ?

c. &&

d. ,

e. ||

Question27

Баллов: 1

The number used to refer to a particular element of an array is called its ________.

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

a. position

b. state

c. port

d. number in array

e. subscript (or index)

Question28

Баллов: 1

Correct mistake in the statement below:

using namespase std;

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

a. using namespace ssd;

b. using namespace std;

c. using namespace sdd;

d. using namesace std;

e. using namespace sdt;

Question29

Баллов: 1

Use a stream manipulator that causes the exponent in scientific notation and the letters in hexadecimal values to print in capital letters

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

a. cout >> uppercase;

b. cout << uppercase;

c. cin>>uppercase;

Question30

Баллов: 1

If there are fewer initializers in an initializer list than the number of elements in the array, the remaining elements are initialized to the last value in the initializer list

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

a. false

b. it depends of the type of an array

c. true

d. it depends on compilator

 

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

Конец формы

Конец формы

 

Preparation for Final Exam MCQ Quiz BIG - Попытка 2

Начало формы

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

Question31

Баллов: 1

When does the code block following while(x<100) execute?

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

a. When x is greater than one hundred

b. Infinite loop

c. When x is less than one hundred

d. When x is equal to one hundred

e. While it wishes

Question32

Баллов: 1

Find statement that performs a fourth element calling in the array "fraction":

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

a. fractions[ 3 ]

b. fractions[ 4 ]

c. fractions( 4 )

d. fractions( 3 )

Question33

Баллов: 1

Which of the following gives the value stored at the address pointed to by the pointer a?

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

a. *a;

b. a;

c. val(a);

d. &a;

e. val->a

Question34

Баллов: 1

What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?

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

a. 1

b. 9

c. 10

d. 5

e. 0

Question35

Баллов: 1

What is the output of the program? #include <iostream> using namespace std; int main() { int a = 5; do { cout << a; a--; } while (a>0); return 0; }

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

a. 543210

b. 54321

c. 4321

d. 1234

e. 12345

Question36

Баллов: 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. bab

b. wow

c. Compiler error

d. heh

e. Undefined behaviour

Question38

Баллов: 1

Refer to the fourth element of array numbers using array subscript notation, pointer/offset notation with the array name as the pointer, pointer subscript notation with nPtr and pointer/offset notation with nPtr

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

a.  numbers[ 3 ] *( numbers + 3 ) &nPtr[ 3 ] *( nPtr + 3 )

b.  numbers[ 3 ] *( numbers + 3 ) nPtr[ 3 ] *( nPtr + 3 )

c.  numbers[ 3 ] &( numbers + 3 ) *nPtr[ 3 ] &( nPtr + 3 )

Question39

Баллов: 1

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 address of variable number1 to pointer variable fPtr.

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

a. fPtr = &number1;

b. *fPtr = number1;

c. fPtr = *number1;

d. fPtr = *&number1;

Question40

Баллов: 1

What will be output ? #include <iostream> using namespace std; int main() { int x = 19; if (x == 19){ int y = 20; cout << x+y << endl; } y = 100; return 0; } 

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

a. Compile-time error

b. 40

c. 38

d. 39

 

Preparation for Final Exam MCQ Quiz BIG - Попытка 2

Начало формы

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

Question41

Баллов: 1

The break statement is required in the default case of a switch selection statement to exit the switch properly

Ответ:

TrueFalse

Question42

Баллов: 1

Find the error in the following program segment and correct the error:

#include <iostream>;

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

a. #include

b. #include “iostream”;

c. #include “iostream” 

Question43

Баллов: 1

What character ends all strings?

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

a. ' '

b. '\n'

c. '\0'

d. ;

e. '.'

Question44

Баллов: 1

Write the function header for a function called evaluate that returns an integer and that takes as parameters integer x and a pointer to function poly. Function poly takes an integer parameter and returns an integer.

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

a. int evaluate( int x, int (*poly))

b. int evaluate( int , int (*)( int ))

c. int evaluate( int x, int (*poly)( int ))

d. int evaluate( int x, int (poly)( int ))

Question45

Баллов: 1

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 ] = "\0"; cout << strlen( s3 ) << endl;

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

a. 0

b. 13

c. NULL

d. 50

Question46

Баллов: 1

Read an integer from the user at the keyboard and store the value entered in integer variable age.

Выберите по крайней мере один ответ:

a. std::cin >> age;

b. std::cout >> age;

c. std::cin >> age

d. std::cin >> int age;

e. std::cout << age;

f. std::cin << age;

Question47

Баллов: 1

Give the function header for the following function. Function intToDouble that takes an integer argument, number, and returns a double-precision, floating-point result.

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

a. float intToDouble( int number)

b. not sure

c. int intToDouble( number)

d. double intToDouble( int number)

e. double intToDouble( double number)

Question48

Баллов: 1

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

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

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

a. no of these

b. delete [] a;

c. I don't know

d. delete a;

e. delete a[];

Question49

Баллов: 1

If ASCII code of 'd' is 100, what is the ASCII code of 'a'?

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

a. 96

b. 97

c. 103

d. 68

e. 65

Question50

Баллов: 1

What does the program below output?

#include<iostream>

usingnamespace std;

Int main() {

 int a[6] = {3,5,1,6,8,2};

 int idx = 0;

 for (int i=0; i<6; i++)

 if (a[idx]>a[i])

 idx = i;

 cout << a[idx] << endl;

 return 0;

}

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

a. None of the given choices.

b. 25

c. 8

d. 1

 

Preparation for Final Exam MCQ Quiz BIG - Попытка 2

Начало формы

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

Question51

Баллов: 1

Find the error in the following program segment void f ( double a); { float a; cout << a << endl; }

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

a. void f ( double a); { cout << a << endl; } 

b. void f ( double a) { cout << a << endl; }

c. void f ( double a) { float a; cout << a << endl; }

d. void f ( double a) { double a;  cout << a << endl; } 

e. not sure

Question52

Баллов: 1

Which of the following statements is true about the program?  I. The program compiles without mistakes. II. The program produces beep when executed. III. There are comments in the program.

#include <iostream> using namespace std; int main() { cout << "hello, iitu!" << endl; return 0; }

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

a. None

b. I only

c. I and II only

d. III only

e. I and III only

Question53

Баллов: 1

Does the following code pass the parameters to the function swap2 by reference? #include <iostream> using namespace std; void swap2(int a ,int b ){ int temp = a; a = b; b = temp;  } int main(){  int a = 5 ,b = 7;  swap2(a,b);  cout << a << " " << b;  return 0; }

Ответ:

TrueFalse

Question54

Баллов: 1

Identify and correct the errors in the following code:  if ( gender == 1 ) 

cout << "Woman" << endl; 

else; 

cout << "Man" << endl;

Выберите по крайней мере один ответ:

a. if ( gender == 1 ) 

cout << "Woman" << endl; 

else 

cout << "Man" << endl;

b. if ( gender = 1 ) 

cout << "Woman" << endl; 

else; 

cout << "Man" << endl;

c. if ( gender = 1 ) 

cout << "Woman" << endl; 

else 

cout << "Man" << endl;

Question55

Баллов: 1

What is the only function all C++ programs must contain?

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

a. start()

b. program()

c. main()

d. end()

e. system()

Question56

Баллов: 1

The address operator & can be applied only to constants and to expressions

Ответ:

TrueFalse

Question57

Баллов: 1

What will be the result of:

int f(int a) { return ++a; } int f(unsigned int a) { return --a; } cout << f(5);

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

a. 5

b. Compiler error

c. 6

d. Undefined behaviour

e. 4

Question58

Баллов: 1

What output will be produced by the following code?

int count = 3;

while (--count > 0)

cout << count << " ";

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

a. 3 2 1 0

b. 3 2 1

c. 0 0 0

d. 2 1

e. 2 1 0

Question59

Баллов: 1

What punctuation is used to signal the beginning and end of code blocks?

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

a. BEGIN and END

b. { }

c. -> and <-

d. START and FINISH

e. ( and )

Question60

Баллов: 1

What is the output of the program?

#include <iostream>

struct BS { unsigned int color; };

struct car : public BS { };

struct truck : public BS { };

struct city : public car, public truck { };

int main(int argc, char** argv)  {  city c;

c.color = 3;

std::cout << c.color << std::endl;

return 0;  }

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

a. ill-formed

b. 0

c. 3

 

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

 

Preparation for Final Exam MCQ Quiz BIG - Попытка 2

Начало формы

Страница:  (Назад)  1  2  3  4  5  6  7  8  9  10  (Далее) 

Question61

Баллов: 1

Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 0 and the value of the variable limit is 10.

((limit/count) > 7) && (limit < 0)

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

a. false

b. Error

c. None of the given choices.

d. true

e. Both true and false

Question63

Баллов: 1

What is the output of the program?

#include<iostream>

usingnamespace std;

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]