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

What kind of library has vector:

  1. #include <vector>

  2. #include <vector.h>

  3. #include <cvector>

  4. #include <vstream>

  5. Doesn’t have;

What cycles are useful for input-output and processing in arrays:

  1. while, do

  2. for, while

  3. do, for

  4. only for

  5. all of the above;

What does this code output?

  1. 0 1 4

  2. 0 0 0 1 4

  3. 1 0 4 0 0

  4. 4 0 1 0 0

  5. 1 0 4;

What associativity and type has this symbol “&&”:

  1. right to left, logical OR

  2. right to left, logical AND

  3. left to right, logical OR

  4. left to right, logical AND

  5. right to left, reference;

What is the X?

  1. memory unit

  2. size of the array

  3. address of the array

  4. array unit

  5. array element;

Where is the error?

  1. int in the prototype of function(3-line)

  2. int in the function(10-line)

  3. function must be above of int main()

  4. function calls wrong

  5. void doesn’t return;

What library should use for “using std::setw”?

  1. #include <iostream>

  2. #include <iostream.h>

  3. #include <conio.h>

  4. #include <iomanip>

  5. #include <fstream>;

Which of the following is called the number of elements in a vector:

  1. element of the vector

  2. item in the vector

  3. size of the vector

  4. size of the array

  5. all of the above;

What does this code output?

  1. nothing

  2. This is not the hello message!

  3. Hello world!

  4. hello

  5. Hello world! This is not the hello message! ;

Why is this code error?

  1. function must be above of int main()

  2. no prototype

  3. int doesn’t return

  4. function calls wrong

  5. need for another library;

Which of the following is wrong?

  1. array and vector haven’t a base type

  2. array cannot change the length

  3. vector: the same purpose as arrays

  4. vector: except can change length while the program is running

  5. vector stores a collection of values of its base type;

Which of the following is a two-dimensional array?

  1. int anarray[2][2];

  2. array anarray[2][2];

  3. int array[2,2];

  4. char array[2];

  5. char anarray[2];

Which of the following gives the memory address of the first element in array a, an array with 50 elements?

  1. a[0];

  2. &a;

  3. a;

  4. a[1];

  5. &a(1);

Which of the following correctly accesses the third element stored in a, an array with 50 elements?

  1. a[3];

  2. a(3);

  3. a;

  4. a[2];

  5. a(2);

What will be output after this code:

  1. 8 8;

  2. 8 9;

  3. 9 9;

  4. 9 10;

  5. 8 10;

Which of the following is incorrect?

  1. cout << b[ 0, 1 ];

  2. cout << b[ 0 ][ 1 ];

  3. cout << b[ 1 ][ 0 ];

  4. cout << b[ 0 ] ;

  5. cout << b[ 0 ][ 1 ][ 2 ][ 3 ][ 5 ];

Find the correct declared vector.

  1. int <vector> v;

  2. int <vector> v(10);

  3. <vector> int v;

  4. vector <int> v;

  5. <int> vector v(10);

What will be the output?

  1. 2

  2. 4

  3. nothing

  4. 2 and 4

  5. 0

Find the wrong initialize.

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

  2. a[ 3 ]={4,7,9,4};

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

  4. a[ 4 ]={1,9,2};

  5. a[ 2 ]={1,2};

How many bytes one integer occupies in the memory?

  1. 2 bytes

  2. 8 bytes

  3. 4 bytes

  4. 32 bytes

  5. 16 bytes

The number of elements in a vector is called:

  1. size of vector

  2. length of vector

  3. index

  4. numbers of vector

  5. value of vector

Which of the following false for array?

  1. change the length

  2. has a base type

  3. stores a collection of values of its base type

  4. has data type

What will be output?

  1. 2 5 90 3 8

  2. 2 3 5 3 65 8 4

  3. nothing

  4. 2 8 3 4

  5. 0

The elements of an array are related by the fact that they have the same ____ and_____.

  1. length and width

  2. name and type

  3. value and variable

  4. length and value

  5. type and variable

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

  1. number

  2. element

  3. value

  4. size

  5. index

Find the error.

  1. it isn’t error

  2. main function is incorrect

  3. array is incorrect

  4. loop for is incorrect

  5. output is incorrect

Which of the following is true?

  1. not included library of string

  2. output is incorrect

  3. array isn’t data type of string

  4. output is incorrect

  5. it is correct

Find the error.

  1. it isn’t error

  2. n isn’t constant number

  3. array incorrect initialized

  4. output is incorrect

  5. function main is incorrect

Which of the following is true?

  1. an array can store many different types of values.

  2. an array index should normally be of data type float

  3. an array can change the length

  4. an initializer list contains more initializers than there are elements in the array

  5. the elements of an array are related by the fact that they have the same name and type

What will be the output?

  1. 0

  2. 8

  3. 7.9

  4. 8.9

  5. 5.8

Function swap() is

a) Means to pass the reference of an argument in the calling function to the corresponding formal parameter of the called function.

b) method of passing arguments to a function copies the reference of an argument into the formal parameter.

c) exchanges the values of the two integer variables pointed to by its arguments.

d) argument reference is passed to the functions just like any other value.

e) all of above

Given the following function declaration and local variable declarations, which of the following is not a correct function call?

a) int myInt;

b) double myDouble;

c) char ch;

d) void someFunction(int& first, double second, char third);

e) all of above

If you write a function that should use call-by-reference, but forget to include the ampersand,

a) the program will run

b) the underline variables

c) the program will run with incorrect results

A function header of a value-returning function with an empty parameter list takes the form ____.

A: functionType functionName()

B: functionType functionName

C: functionName

D: functionType functionName (0)

E: functionType

A value-returning function can be used ____.

A: in an assignment statement

B: in an output statement

C: as a parameter in a function call

D: none of them

E: all of the above

Every recursion should have the following characteristics.

a) A simple base case which we have a solution for and a return value. Sometimes there is more than one base case.

b) A way of getting our problem closer to the base case. I.e. a way to chop out part of the problem to get a somewhat simpler problem.

c) A recursive call which passes the simpler problem back into the function.

d) All of them

e) None of them

What is the output of this program?

a) 9

b) 10

c) error

d) 11

d) 12

What is the output of this program?

a) In swap 105 In main 105

b) In swap 105 In main 510

c) In swap 510 In main 105

d) In swap 501 In main 105

e) None of the mentioned

Which value we cannot assign to reference?

a) integer

b) floating

c) unsigned

d) null

e) all of them

What is the output of this program?

a) 1468

b) 2812

c) 2614

d) 2693

e) none of the mentioned

What error would the following function five on compilation?

a) Missing parentheses in return statement

b) Redeclaration of a

c) Declaration of b

d) No error

e) Function should be define as int f(int a, int b)

It is necessary to declare the type of a function in the calling program if the function

a) Returns an integer

b) Returns a non-integer value

c) Is not defined in the same file

d) Return nothing

e) None of these

What will be the value returned by the following function, when it is called with a value 11?

a) Function does not return any value, because it goes into an infinite loop

b) 1011

c) 11

d) 1010

e) None of these

A function can make

a) One throw

b) One throw of each programmer defined type

c) One throw of each scale type

d) As many throws of as many types as necessary

e) None of them

Empty parameter lists

a) void or leave parameter list empty

b) Indicates function takes no arguments

c) Function print takes no arguments and returns no value

d) All of them

e) None of them

The default parameter passing mechanism is

a) Call by value

b) Call by reference

c) Call by value result

d) Call by parameter

e) None of above

Use of functions

a) Helps to avoid repeating a set of statements many times

b) Enhances the logical clarity or the program

c) Helps to avoid repeated programming across programs

d) None of above

e) All of the above

Which of the following function prototype is perfectly acceptable?

A.

int Function(int Tmp = Show());

B.

float Function(int Tmp = Show(int, float));

C.

Both A and B.

D.

float = Show(int, float) Function(Tmp);

E. Int FunctionShow

Where the default values of parameter have to be specified?

A.

Function call

B.

Function definition

C.

Function prototype

D.

Both B or C

E. Function value

If the type specified of parameters of a function is followed by an ampersand & that function call is

a. pass by value

b. pass by reference

c. pass by call

d. pass by function

e. none of them

Function templates can accept

A) any type of parameters

B) only one parameter

C) only parameters of the basic type

D) only parameters of the derived type

E) only function

Inline function is ____

a) Functions with same name and different parameters

b) Asks the compiler to copy code into program instead of making function call

c) Function call with omitted parameters

d) Compact way to make overloaded functions

e) Functions that call themselves

Function Overloading is ____

a) Functions with same name and different parameters

b) Asks the compiler to copy code into program instead of making function call

c) Function call with omitted parameters

d) Compact way to make overloaded functions

e) Functions that call themselves

Differences between references and pointers:

a) You cannot have NULL references. You must always be able to assume that a reference is connected to a legitimate piece of storage.

b) Once a reference is initialized to an object, it cannot be changed to refer to another object. Pointers can be pointed to another object at any time.

c) A reference must be initialized when it is created. Pointers can be initialized at any time.

d) References and pointers are similar

e) All of them

Default Arguments

a) Helps to avoid repeating a set of statements many times

b) Function call with omitted parameters

c) A reference must be initialized when it is created. Pointers can be initialized at any time.

d) References and pointers are similar

e)All of them

Call by value

a) Copy of data passed to function

b) Changes to copy do not change original

c)Prevent unwanted side effects

d) all of them

e) a and b

Call by reference

a) Function can directly access data

b) Changes affect original

c) Prevent unwanted side effects

d) a and b

e) c and b

What is the output of this program?

a)

b)

c)

d)

e)

) Unary scope resolution operator is

a) :;

b) ::

c) : & ()

d) - & ()

e) : & *

Recursive function

a) Functions that call themselves

b) Can only solve a base case

c) a and b

d) none of them

e) all

The synonym of logical negation operator:

a) and b) or c) logical affirmative d) logical NOT e) no answer

It’s statement can be used to implement any counter-controlled loop:

a) while b) structure c) break d) cout e) cin

After “while (condition)” references:

a) … b) ; c) : d) , e) .

in this code forgotten:

  1. do b) class c) break d) if e) this code correct

A logical operator && means:

a) not b) and c) or d) yes e) no answer

The … multiple-selection statement is used to perform many different actions based on the possible values of a variable or expression.

a) class b) cin c) function d) switch e) do

|| (logical OR) operator truth table. If expression1 – false and expression2 – false, than expression1 || expression2 is:

a) false b) true c) false and true d) no answer e) nothing

logical operators are used to:

a) form simple conditions by combining simple conditions.

b) form one code.

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