Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 An array is NOT: 1 Made up of different data types. 2 Subscripted by integers. 3 A consecutive group of memory chunks. 4

Question 1

An array is NOT:

1

Made up of different data types.

2

Subscripted by integers.

3

A consecutive group of memory chunks.

4

None of the choices.

Question 2

How many times is the body of the loop executed?

int i=1; while(true) { cout << i; if(++i==5) break; }

Forever

1

4

2

5

3

6

4

0

Question 3

What is wrong with the following piece of code fragment?

1 string name;

2 name = PCC;

3 switch(name)

4 {

5 case BCC: cout << BCC;

6 break;

7 case PCC: cout <

8 break;

9 }

1

Default statement is missing.

2

There is an error in Line 2

3

Strings cannot be used with switch statement.

4

Semi colon is missing at the end of the switch statement.

5

None of the choices.

Question 4

What is stored in the variable name result?

string str1= John Smith; string str2 = John Doe; bool result = (str11 < str2);

True

False

Undefined

None of the choices.

Question 5

In a brief sentence describe what is wrong with the following code:

1 int minval(int arr[], int size) 2 { 3 int localmin; 4 for (int i=0; i

Question 6

After the following code snippet is pre-processed, the statement in Line 5 expands to which of the following:

1 # See rand() in http://www.cplusplus.com/reference/cstdlib/rand/ 2 #include 3 4 #define R(n) random()%n

5 int value = R(j-i+1);

int value = rand()%j-i+1;

int value = random()%j-i+1;

int value = R(j-i+1)%j-i+1;

None of the choices.

Question 7

We have the following 2 char arrays with identical character sequences in them. The easiest way to compare if both arrays have the same content is to check for the result of arr1==arr2.

char arr1[] = {'p', 'c', 'c'}; char arr2[] = {'p', 'c', 'c'};

True

False

Question 8

We can copy str1 into str2 by the following:

char str1[10] = "PCC";

char str2[10];

strcpy(str1, str2);

True

False

Question 9

This question may have 0 to multiple answers. Choose all that apply. Examine the following code and identify the Line number(s) where a bug may exist.

1 char str[4];

2 for (i=0; i<3; i++)

3 str[i]=getchar();

4 cout << str;

Line 2

Line 3

Line 4

None of the choices.

Question 10

The following code is CORRECT:

char str[3] = "pcc"; int i;

True

False

Question 11

Generally, we DON'T need to write error handlers (namely, functions that are designed to catch input, functional, or output errors) for errors caught at compile time.

True

False

Question 12

This question may have 0 to multiple answers. Choose all that apply. Which of the following is TRUE about a function:

Passing lots of arguments into a function is costly compared to alternatives.

Having too many function calls in a program slows it down.

A function declaration tells the compiler about a function's name, return type, and parameters.

A function can return AT MOST 1 value back to its caller.

Question 13

When passing an array into a function, we must also pass in the array's size into the function.

True

False

Question 14

This question may have 0 to multiple answers. Choose all that apply. Converting from data type _______ to data type ______ will result in the loss of data.

short, long

float, double

int, char

char, bool

None of the choices.

Question 15

A data type that can have values ONLY between the range 0 to 65535 is a:

2-byte int

4-byte int

2-byte unsigned int

4-byte unsigned int

Question 16

This question may have 0 to multiple answers. Choose all that apply. Consider the following for loop:

for (int x = 1; x < 5; increment) { cout << x + 1 << endl; }

If the last value printed is 5, which of the following might have been used for increment?

x++

++x

x += 1

None of the choices.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions