Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.An array is NOT: A Made up of different data types. B Subscripted by integers. C A consecutive group of memory chunks. D None of

1.An array is NOT:

A Made up of different data types.
B Subscripted by integers.
C A consecutive group of memory chunks.
D None of the choices.

2.How many times is the body of the loop executed?

int i=1; while(true) { cout << i; if(++i==5) break; } 
A. Forever
B. 4
C. 5
D. 6
E. 0

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 < 
A Default statement is missing.
B There is an error in Line 2
C Strings cannot be used with switch statement.
D Semi colon is missing at the end of the switch statement.
E None of the choices.

4.What is stored in the variable name result?

string str1= John Smith; string str2 = John Doe; bool result = (str11 < str2); 
A True
B False
C Undefined
D None of the choices.

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

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);
A int value = rand()%j-i+1;
B int value = random()%j-i+1;
C int value = R(j-i+1)%j-i+1;
D

None of the choices.

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

8.We can copy str1 into str2 by the following:

char str1[10] = "PCC"; char str2[10]; strcpy(str1, str2);
True
False

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;

A

Line 2
B Line 3
C Line 4
D None of the choices.

10. The following code is CORRECT:

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

False

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

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

A Passing lots of arguments into a function is costly compared to alternatives.
B Having too many function calls in a program slows it down.
C A function declaration tells the compiler about a function's name, return type, and parameters.
D A function can return AT MOST 1 value back to its caller.

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

A True
B

False

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.

A short, long
B float, double
C int, char
D char, bool
E None of the choices.

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

A

2-byte int
B 4-byte int
C 2-byte unsigned int
D 4-byte unsigned int

16. This question may have 0 to multiple answers. Choose all that apply. How do you concatenate two C++ strings, str1 and str2?

A concate(str1, str2);
B strconcate(str1, str2);
C str1 = str2;
D str1.add(str2);
E str1 += str2;

17. Based on the Problem Description, we need to keep the character count for every one of the 128 possible characters. Which of the following statements illustrates the use of arr (array created from the last problem) to increment the ASCII_CHARACTER count by 1? ASCII_CHARACTER can be any one of the first 128 characters in the ASCII Table (Links to an external site.)Links to an external site. (not the Extended ASCII Table).

A arr[ASCII_CHARACTER-97]++;
B arr[ASCII_CHARACTER] = ASCII_CHARACTER++;
C arr[ASCII_CHARACTER]++;
D arr[ASCII_CHARACTER-65]++;
E None of the choices.

18. Based on the Problem Description, the input may be the combination of any one of the 128 characters in the ASCII table (Links to an external site.)Links to an external site.. Write a STATEMENT (not the entire program) to create/instantiate an array of 128 characters called arr.

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

Students also viewed these Databases questions

Question

Identify how culture affects appropriate leadership behavior

Answered: 1 week ago