cs 150
An enumeration type can be passed as a parameter to a function only by value. A.True B.False
B
during program execution the contents of a variable can be changed True or false
True
Variables that are created during program execution are called static variables. a. True b. False
b
In C++, you can create aliases to a previously defined data type by using the ____ statement. a. using b. namespace c. alias d. typedef
d
In C++, you declare a pointer variable by using the ____ symbol. a. @ b. # c. & d. *
d
Before a variable in C++ is used, it must be a) defined b) initialized c) used in some expression d) begin with a capital letter e) contain only letters, digits and underscores.
defined
Which of the following loops does not have an entry condition?
do...while loop
Which of the following loops is guaranteed to execute at least once?
do...while loop
Which of the following is a repetition structure in C++? a. do...while b. while...do c. if d. switch
do..while
Pick the C++ keywords out of the following list. a) while b) total_weight c) double d) if e) number_of_bars
while, double, if
Suppose that x is an int variable and y is a double variable and the input is: 10 20.7 Choose the values after the following statement executes: cin >> x >> y;.
x = 10, y = 20.7
A class is an example of a structured data type. A.True B.False
A
A function can return a value of the type struct. A.True B.False
A
A member function of a class that only accesses the value(s) of the data member(s) is called a(n) ____ function. A. accessor B. mutator C. constructor D. destructor
A
A variable declared within a function block is said to be local to the function A.True B.False
A
As parameters to a function, class objects can be passed by reference only. A. True B. False
A
Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList? a. 0 through 99 b. 0 through 100 c. 1 through 100 d.1 through 101
A
C++ allows functions to have default parameters. A.True B.False
A
The components of a struct are called the ____ of the struct. A.Variables B.Identifiers C.Elements D.members
D
What is the output of the following C++ code? count = 1; num = 25; while (count < 25) { num = num - 1;count++; } cout << count << " " << num << endl; Answers: a. 24 0 b. 24 1 c. 25 0 d. 25 1
D
What is the output of the following C++ code? int alpha[5] = {2, 4, 6, 8, 10}; int j; for (j = 4; j >= 0; j--) cout << alpha[j] << " "; cout << endl; a. 2 4 6 8 10 b. 4 3 2 1 0 c. 8 6 4 2 0 d. 10 8 6 4 2
D
What is the output of the following C++ code? num = 10; while (num > 10) num = num - 2; cout << num << endl; a. 0 b. 6 c. 8 d. 10
D
What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A': cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl; break; case 'D': cout << "section 4" <<endl; break; default:cout << "section 5" <<endl; } Answers:a. section 2 b. section 3 c. section 4 d. section 5
D
What is the output of the following code? char lastInitial = 'S'; switch (lastInitial) { case 'A':cout << "section 1" <<endl; break; case 'B': cout << "section 2" <<endl; break; case 'C': cout << "section 3" <<endl;break; case 'D': cout << "section 4" <<endl; break; default:cout << "section 5" <<endl; } Answers: a. section 2 b. section 3 c. section 4 d. section 5
D
What is the output of the following loop? count = 5; cout << 'St'; do { cout << 'o'; count--; } while (count <= 5); Answers: a. St b. Sto c. Stop d. This is an infinite loop.
D
Which of the following correctly declares name to be a character array and stores "William" in it? a. char name[6] = "William"; b. char name[7] = "William"; c. char name[8] = 'William'; d. char name[8] = "William";
D
Which of the following statements creates an anonymous type? A.enum grades {A, B, C, D, F}; B.enum grades {}; C.enum {}; D.enum {A, B, C, D, F} grades;
D
Which of the following statements declares the studentGrade variable? A.enum studentGrade {A, B, C, D, F}; B.enum int {A, B, C, D, F} studentGrade; C.enum studentGrade {A, B, C, D, F} grades; D.enum grades {A, B, C, D, F} studentGrade;
D
The following is a legal C++ enumeration type: enum colorType {BLUE, GREEN, PINK, YELLOW, RED}; a. True b. False
a
The syntax for accessing a struct member is structVariableName____. a. [memberName] b. .memberName c. $memberName d. *memberName
a
To access a structure member (component), you use the struct variable name together with the member name; these names are separated by a dot (period). A.True B.False
a
Which of the following is a valid C++ statement? a. typedef int integer; b. typedef int; c. typedef integer int; d. typedef integer;
a
Which of the following statements declares alpha to be an array of 25 components of the type int? a. int alpha[2][5]; b. int array alpha[25]; c. int alpha[25]; d. int array alpha[25][25];
a
Suppose that x is an int variable, ch is a char variable, and the input is: 276. Choose the values after the following statement executes: cin >> ch >> x;
ch = '276', x = '.'
Suppose that x and y are int variables. Which of the following is a valid input statement?
cin >> x >> y;
A struct variable can be passed as a parameter ____. a. only by const b. only by reference c. only by value d. either by value or by reference
d
What does <= mean?
less than or equal to
The scope of an identifier refers to those parts of the program where it is accessible. A.True B.False
true
To use cin and cout, the program must include the header file iostream and either include the statement using namespace std; or refer to these identifiers as std::cin and std::cout.
true
A function can return a value of the type array. A.True B.False
B
Suppose that x is an int variable. Which of the following expressions always evaluates to true?
(x > 0) || ( x <= 0)
Aggregate input/output operations are allowed on a struct variable. True or False
False
Assume you have three int variables: x = 2, y = 6, and z. Choose the value of z in the following expression: z = (y / x > 0) ? x : y;.
2
What is the value of x after the following statements execute? int x = 5; int y = 30; dox = x * 2; while (x < y); Answers: a. 5 b. 10 c. 20 d. 40
40
The value of the expression 20.0 * (9/5) + 32.0 is a) 68.0 b) 52.0 c) incorrect expression so there is no valued) 32.0 e) incorrect expression , the / should be %
52
Consider the following code. (Assume that all variables are properly declared. )cin >> ch; while (cin) { cout << ch; cin >> ch; } This code is an example of a(n) ____ while loop. Answers: a.sentinel-controlled b.flag-controlledc.EOF-controlled d.counter-controlled
A
Consider the following declaration: char str[15];. Which of the following statements stores "Blue Sky" into str? a. strcpy(str, "Blue Sky"); b. str[15] = "Blue Sky"; c. strcpy("Blue Sky"); d. str = "Blue Sky";
A
Consider the following function definition. double funcTest(string name, char u, int num, double y) Which of the following is correct function prototype of the function funcTest? A.double funcTest(string, char, int, double); B.double funcTest(string n, char ch, int x, int t); C.double funcTest(name, u, num, y); D.int funcTest(string, char, int, double)
A
Consider the statement int list[10][8];. Which of the following about list is true? a. list has 10 rows and 8 columns. b. list has a total of 108 components. c. list has a total of 18 components. d. list has 8 rows and 10 columns.
A
Data in a struct variable must be read one member at a time. A.True B.False
A
Functions Cannot Return a Value of the Type Array A.True B.False
A
Given the following function: int strange(int x, int y) { if (x > y) return x + y; else return x - y; } what is the output of the following statement? cout << strange(4, 5) << endl; a.-1 b.1 c.9 d.20
A
If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ____________________ function and use the appropriate reference parameters to return the values. A.void B.value-returning
A
If the heading of a member function of a class ends with the word const, then the function member can modify the member variables. A. True B. False
A
In C++, the null character is represented as ____. A.'\0' B."\0" C.'0' D."0"
A
In C++, the null character is represented as ____. a. '\0' b. "\0" c. "0" d. '0'
A
In static variable, memory remains allocated as long as the program executes A.True B.False
A
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered. a. True b. False
A
Suppose that gamma is an array of 50 components of type int and j is an int variable. Which of the following for loops sets the index of gamma out of bounds? a. for (j = 0; j <= 50; j++) cout << gamma[j] << " "; b. for (j = 0; j <= 49; j++) cout << gamma[j] << " "; c. for (j = 1; j < 50; j++) cout << gamma[j] << " "; d. for (j = 0; j <= 48; j++) cout << gamma[j] << " ";
A
The ________ of a function consists of the function name and its formal parameter list. A.Signature B.Body C.Call D.All the above
A
The control statements in the for loop include the initial statement, loop condition, and update statement. a. True b. False
A
The control variable in a flag-controlled while loop is a bool variable.S a. True b. False
A
The syntax for accessing a struct member is structVariableName____. A..memberName B.*memberName C.[memberName] D.$memberName
A
What is the output of the following C++ code? int x = 55; int y = 5; switch (x % 7) { case 0: case 1: y++; case 2: case 3: y = y + 2; case 4: break; case 5: case 6: y = y - 3; } cout << y << endl; Answers: a. 2 b. 5 c. 8 d. 10
A
When one control statement is located within another, it is said to be ____. a. closed b. nested c. compound d. blocked
A
When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter A.reference B.global C.constant D.value
A
Which of the following expressions correctly determines that x is greater than 10 and less than 20? Answers: a. 10 < x && x < 20 b. 10 < x < 20 c. (10 < x < 20) d. 10 < x || x < 20
A
Which of the following is a relational operator? Answers: a. == b. ! c. &&d. =
A
Which of the following is the "not equal to" relational operator? a. != b. ! c. | d. &
A
Which of the following statements declares alpha to be an array of 25 components of the type int? A.int alpha[25]; B.int array alpha[25]; C.int alpha[2][5]; D.int array alpha[25][25];
A
Which of the following struct definitions is correct in C++? A.struct studentType{ int ID;}; B.struct studentType{ string name; int ID; double gpa;}
A
You can use an assignment statement to copy the contents of one struct into another struct of the same type. A.True B.False
A
You can use either a(n) ____ or a ____ to store the value of a logical expression. Answers: a. int, bool b. float, string c. float, double d. char, string
A
char nameList[100]; Which of the following ranges is valid for the index of the array nameList? A.0 through 99 B.0 through 100 C.1 through 100 D.1 through 101
A
n Aarray is a collection of fixed number components all of the same data type A.True B.False
A
A variable declared outside any function is said to be a local variable. A.True B.False
B
Aggregation is allowed on arrays in C++ A.True B.False
B
Arrays can be passed as parameters to a function by value A.True B.False
B
Consider the following statement: double alpha[10][5];. The number of components of alpha is ____. a. 15 b. 50 c. 100 d. 150
B
Given the following function prototype: int test(float, char); which of the following statements is valid? a.cout << test("12.0", '&'); b.int u = test(5.0, '*'); c.cout << test(12, &); d.cout << test('12', '&');
B
If an object is created in a user program, then the object can access both the public and private members of the class. A. True B. False
B
No arithmetic operations are allowed on the enumeration type. A.True B.False
B
Suppose j, sum, and num are int variables, and the input is 26 34 61 4 -1. What is the output of the code? sum = 0; cin >> num; for (int j = 1; j <= 4; j++) { sum = sum + num; cin >> num; } cout << sum << endl; a.124 b.125 c.126 d.127
B
The following is a legal C++ enumeration typeenum colorType {BLUE, GREEN, 2PINK, YELLOW, RED}; A.True B.False
B
What is the data type of variable x in the following C++11 code: int y= 2; double z = 3.5; auto x = z * y; a) int b) double c) auto d) syntax error
B
What is the output of the following code? enum courses {ALGEBRA, BASIC, PASCAL, PHILOSOPHY, ANALYSIS}; courses registered; registered = ALGEBRA; cout <<> A.ALGEBRA B.0 C.BASIC D.PASCAL
B
What is the output of the following statements?cout << setfill('*');cout << "12345678901234567890" << endlcout << setw(5) << "18" << setw(7) << "Happy"<< setw(8) << "Sleepy" << endl; a)12345678901234567890 **18**Happy*Sleepy b) 12345678901234567890 **18Happy*Sleepy c) 12345678901234567890 **18HappySleepy
B
Which of the following will cause a logical error if you are attempting to compare x to 5? Answers :a. if (x >= 5) b. if (x = 5) c. if (x == 5) d. if (x <= 5)
B
enum cars {FORD, GM, TOYOTA, HONDA};cars domesticCars = FORD; The statement: domesticCars =static_cast(domesticCars + 1); sets the value of domesticCars to ____. A.FORD B.GM C.TOYOTA D.HONDA
B
he public members of a class must be declared before the private members. A.True B.False
B
A function prototype is ____. a. a declaration and a definition b. a definition, but not a declaration c .a declaration, but not a definition d.a comment line
C
A variable listed in a header is known as a(n) ____ parameter. a. actual b. local c. formal d. function
C
Assume you have the following declaration int beta[50];. Which of the following is a valid element of beta? a. beta['2'] b. beta['50'] c. beta[0] d. beta[50]
C
Given the following function: int next(int x) { return (x + 1); } what is the output of the following statement? cout << next(next(5)) << endl; a.5 b.6 c.7 d.8
C
If a member of a class is ____, you cannot access it outside the class. A.Public B.Automatic C.PrivateD.static
C
In ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s). Answers: a.sequence b.selection c.looping d.branching
C
Suppose that sales is an array of 50 components of type double. Which of the following correctly initializes the array sales? A.for (int 1 = 1; j <= 49; j++) sales[j] = 0; B.for (int j = 1; j <= 50; j++) sales[j] = 0; C.for (int j = 0; j <= 49; j++) sales[j] = 0.0; D.for (int j = 0; j <= 50; j++) sales[j] = 0.0;
C
To guarantee that the member variables of a class are initialized, you use ____. A. accessor B. mutator C. constructor D. destructor
C
What is the output of the following C++ code? int j; for (j = 10; j <= 10; j++) cout << j << " "; cout << j << endl; Answers: a.10 b.10 10 c.10 11 d.11 11
C
What is the output of the following C++ code? int x = 35; int y = 45; int z; if (x > y) z = x + y; else z = y - x; cout << x << " " << y << " " << z << endl; a. 35 45 80 b. 35 45 -10 c. 35 45 10 d. 35 45 0
C
What is the value of alpha[2] after the following code executes? int alpha[5]; int j; for (j = 0; j < 5; j++) alpha[j] = 2 * j + 1; a. 1 b. 4 c. 5 d. 6
C
What is the value of x after the following statements execute? int x; x = (5 <= 3 && 'A' < 'F') ? 3 : 4 Answers: a. 2 b. 3 c. 4 d. 5
C
Which of the following correctly declares and initializes alpha to be an array of four rows and three columns with the component type int? a. int alpha[4][3] = {0,1,2; 1,2,3; 2,3,4; 3,4,5}; b. int alpha[4][3] = {0,1,2: 1,2,3: 2,3,4: 3,4,5}; c. int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}}; d. int alpha[4][3] = {{0,1,2} {1,2,3} {2,3,4} {3,4,5}};
C
Which of the following correctly declares name to be a c-string and stores "William" in it? A.char name[6] = "William"; B.char name[7] = "William"; C.char name[8] = "William"; D.char name[8] = 'William';
C
Which of the following is a valid C++ statement? A.typedef integer; B.typedef int; C.typedef int integer; D.typedef integer int;
C
A destructor has the character ____, followed by the name of the class. A. . B. :: C. # D. ~
D
A variable or expression listed in a call to a function is called the ____. a. type of the function b. data type c. formal parameter d. actual parameter
D
Functions that do not have a return type are called ____ functions. a.null b.zero c.empty d.void
D
Reference parameters are useful in which of the following situations A.When the value of the actual parameter needs to be changed B.When you want to return more than one value from a function C.When passing the address would save memory space and time relative to copying a large amount of data D.All the above
D
Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference. True False
False
Assume that all variables are properly declared. The following for loop executes 20 times .for (i = 0; i <= 20; i++) cout << i;
False
Given the declaration int list[20]; the statement list[12] = list[5] + list[7]; updates the content of the twelfth component of the array list. True False
False
If an array index goes out of bounds, the program always terminates in an error. True False
False
In C++, both ! and != are relational operators.
False
Suppose list is a one dimensional array of size 25, wherein each component is of type int. Further, suppose that sum is an int variable. The following for loop correctly finds the sum of the elements of list. sum = 0; for (int i = 0; i < 25; i++) sum = sum + list; True False
False
The expression (x >= 0 && x <= 100) evaluates to false if either x < 0 or x >= 100.
False
The following return statement returns the value 10. return 10, 16; True False
False
The following statements will result in input failure if the input values are not on a separate line. (Assume that x and y are int variables. )cin >> x; cin >> y;
False
The number system used by a computer is base 10
False
The program that loads first when you turn on your computer is called the operating system
False
The result of a logical expression cannot be assigned to an int variable, but it can be assigned to a bool variable.
False
The statement int list[25]; declares list to be an array of 26 components, since the array index starts at 0. True False
False
The C++ operator ____ is used to create dynamic variables. a. new b. dereferencing c. dynamic d. virtual
a
Given the C++ output statements. What is the output of these lines of code? Explain. cout << "If you have "; cout << "a number of pods "; cout << "you can quit."; cout << "\n";
If you have a number of pods you can quit.Explanation: Note that there is a <cr> emitted by the code, which puts the next output position on the next line at the left end.
Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5. n = 1; while (n < 5) { n++; cout << n << " "; }
Trie
A control structure alters the normal sequential flow of execution in a program.
True
A program should have a comment on every line True or false
True
All components of an array are of the same data type. True False
True
Assume that all variables are properly declared. The following statement in a value-returning function is legal. if (x % 2 == 0) return x; else return x + 1; True False
True
In C++, && has a higher precedence than ||.
True
In C++, a function prototype is the function heading without the body of the function. True False
True
Once you write and properly debug a function, you can use it in the program (or different programs) again and again without having to rewrite the same code repeatedly. True False
True
Suppose P and Q are logical expressions. The logical expression P && Q is true if both P and Q are true.
True
The data type of a variable in a return statement must match the function type. True False
True
The number of input data extracted by cin and >> depends on the number of variables appearing in the cin statement.
True
The one place where C++ allows aggregate operations on arrays is the input and output of C-strings. True False
True
When reading data into a char variable, after skipping any leading whitespace characters, the extraction operator >> finds and stores only the next character; reading stops after a single character.
True
When you pass an array as a parameter, the base address of the actual array is passed to the formal parameter. True False
True
You can use the function getline to read a string containing blanks.
True
1. Suppose that you have the following declaration. enum cars {FORD, GM, TOYOTA, HONDA}; cars domesticCars = FORD; The statement: domesticCars = static_cast<cars>(domesticCars + 1); sets the value of domesticCars to ____. a. GM b. HONDA c. TOYOTA d. FORD
a
A memory leak is an unused memory space that cannot be allocated. a. True b. False
a
A pointer variable is a variable whose content is a memory address. a. True b. False
a
Consider the following statements: struct personalInfo { string name; int age; double height; double weight; }; struct commonInfo { string name; int age; }; personalInfo person1, person2; commonInfo person3, person4; Which of the following statements is valid in C++? a. person2 = person1; b. person1 = person3; c. person2 = person3; d. person2 = person4;
a
Consider the following struct definition: struct rectangleData { double length; double width; double area; double perimeter; }; Which of the following variable declarations is correct? a. rectangleData myRectangle; b. struct rectangleData(); c. rectangleData rectangle = new rectangleData(); d. rectangle rectangleData;
a
Given the declaration int *p; The statement p = new int[50]; dynamically allocates an array of 50 components of type int and p contains the base address of the array. a. True b. False
a
If p is a pointer variable, the statement p = p + 1; is valid in C++. a. True b. False
a
In C++, [ ] is called the array subscript operator. a. True b. False
a
In C++, ____ is called the scope resolution operator. a. :: b. . c. : d. ?
a
In C++, namespace is a reserved word. a. True b. False
a
In a ____ copy, two or more pointers have their own data. a. deep b. dynamic c. static d. shallow
a
No arithmetic operations are allowed on the enumeration type. a. True b. False
a
1. What is the value assigned to the variable in each of these cases? Explain curious results. Be careful !int x, y; a) x = 1/2; b) y = 3.0/2.0;double z, w, t; c) z = 1/2; d) w = 3/2; e) t = 3.0/2.0;
a) 0 is assigned.1/2 is computed using truncating integer divide which gives 0. b) 1.5 is calculated and assigned. The fractional part is discarded; 1 is stored. c) 0 is calculated because 1/2 is done with truncating integer divide, gives 0. The floating point value 0.0 is stored. d) 1 is calculated, because truncating int divide, 1.0 is stored e) 1.5 is calculated and stored.
What is the value assigned to the variable in each of these cases? Explain curious results. Be careful! int x, y; a) x = 1/2; b) y = 3.0/2.0; double z, w, t; c) z = 1/2; d) w = 3/2; e) t = 3.0/2.0;
a) 0 is assigned.1/2 is computed using truncating integer divide which gives 0. b) 1.5 is calculated and assigned. The fractional part is discarded; 1 is stored. c) 0 is calculated because 1/2 is done with truncating integer divide, gives 0. The floating point value 0.0 is stored. d) 1 is calculated, because truncating int divide, 1.0 is stored e) 1.5 is calculated and stored.
An array created during the execution of a program is called a(n) ____ array. a. static b. dynamic c. list d. execution
b
Consider the following statements: struct rectangleData { double length; double width; double area; double perimeter; }; rectangleData bigRect; Which of the following statements is valid in C++? a. cout << bigRect; b. cout << bigRect.length; c. cin >> bigRect.length >> width; d. cout << length;
b
Given the declaration int *a;, the statement a = new int[50]; dynamically allocates an array of 50 components of the type ____. a. int* b. int c. pointer d. address
b
In C++, ____ is called the address of operator. a. # b. & c. * d. ->
b
In C++, pointer variables are declared using the reserved word pointer. a. True b. False
b
In C++, the ____ symbol is an operator, called the member access operator. a. ,(comma) b. .(dot) c. :(colon) d. $ (dollar sign)
b
In C++, the dot operator has lower precedence than the dereferencing operator. a. True b. False
b
In C++, the member access operator arrow is >>. a. True b. False
b
In the statement int* p, q; p and q are pointer variables. a. True b. False
b
Suppose str = "xyzw";. After the statement str[2] = 'Y'; The value of str is "____". a. xyzw b. xzYw c. xyYw d. xYzw
b
The code int *p; declares p to be a(n) ____ variable. a. num b. pointer c. new d. address
b
Typically, in a program, a struct is defined ____ in the program. a. in the main function b. before the definitions of all the functions c. after the definitions of all the functions d. in any function
b
Which of the following is an allowable aggregate operation on a struct? a. Comparison b. Assignment c. Arithmetic d. Input/output
b
You can assign the value of one struct variable to another struct variable of ____ type. a. simple data b. the same c. an array d. any
b
Which of the following names might give the human reader some hint about the data that is stored in them? a) aa, bb, cc b) speed, distance, time c) hypotenuse, leg1, leg2 d) v1, v2, v3 e) principal, interest, payment
b c e
A ____ sign in front of a member name on a UML diagram indicates that this member is a protected member. a. + b. - c. # d. $
c
A ____ sign in front of a member name on a UML diagram indicates that this member is a public member. a. - b. $ c. + d. #
c
A class ____ automatically executes whenever a class object goes out of scope. a. pointer b. exception c. destructor d. constructor
c
Consider the following statements: struct rectangleData { double length; double width; double area; double perimeter; }; rectangleData bigRect; Which of the following statements is valid in C++? a. cin >> bigRect; b. perimeter = 2 * (length + width); c. cin >> bigRect.length; d. area = length * width;
c
Consider the following statements: struct supplierType { string name;int supplierID; }; struct applianceType { supplierType supplier;string modelNo;double cost; }; applianceType applianceList[25]; Which of the following statements correctly initializes the cost of each appliance to 0? a. for (int j = 1; j < 25; j++)applianceList.cost[j] = 0; b. applianceList.cost[25] = 0; c. for (int j = 0; j < 25; j++)applianceList.cost[j] = 0; d. applianceList.cost = 0;
c
In C++, ____ is a reserved word. a. typecc b. alias c. typedef d. deftype
c
In a ____ copy, two or more pointers of the same type point to the same memory. a. dynamic b. static c. shallow d. deep
c
Suppose str = "ABCDEFGHI". The output of the statement cout << str.length() << endl; is ____. a. 7 b. 8 c. 9 d. 10
c
Suppose that str1, str2, and str3 are string variables. After the following statements execute, the value of str3 is "____". str1 = "abc"; str2 = "xyz"; str3 = str1 + '-' + str2; a. abc b. xyz c. abc-xyz d. xyz-abc
c
The C++ operator ____ is used to destroy dynamic variables. a. destroy b. * c. delete d. ˜
c
Consider the following statements. struct circleData { double radius; double area; double circumference; }; circleData circle; Which of the following statements is valid in C++? a. cin >> circle; b. cin >> circle.radius;circle.area = 3.14 * radius * radius; c. cin >> circle.radius;circle.area = 3.14 * circle.radius * radius; d. cin >> circle.radius;
d
Consider the following statements: struct studentType1 { string name; int ID; double gpa; }; studentType1 student1, student2; struct studentType2 { string name; int ID; double gpa; }; studentType2 student3, student4; Which of the following statements is valid in C++? a. student2 = student3; b. student2.ID = ID; c. student1 = student4; d. student1.ID = student3.ID;
d
Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s). a. one b. two c. four d. eight
d
The ____ function is used to interchange the contents of two string variables. a. traverse b. iterator c. change d. swap
d
The output of the statement: cout << pow(3.0, 2.0) + 5 << endl; is ____. a.11.0 b.12.0 c.13.0 d.14.0
d
To compare struct variables, you compare them ____. a. index-wise b. by value c. by reference d. member-wise
d
In C++ the variables Alpha, ALPHA and AlphA are the same identifier.
false, C++ is case sensitive
In C++ the compiler will infer the type intended for a variable from the context in which the variable occurs.
false, you have to declare all variables before use
A(n) ____-controlled while loop uses a bool variable to control the loop.
flag
When you want to process only partial data, you can use the stream function ____ to discard a portion of the input.
ignore
A loop that continues to execute endlessly is called a(n) ____ loop.
infinite
In C++, a legal identifiers may contain these kinds of characters _______________, ______________, ______________
letters, digits, underscores (Some implementations allow a very few other characters such as $.)
Which of the following types are not built into the C++ language: a) bool b) real c) short d) int e) long f) double
real
Which executes first in a do...while loop? :a. the statement b. update statement c. loop condition d. the expression
the statement
A function can return a value of the type struct true or false
true
Suppose x is 5 and y is 7. Choose the value of the following expression: (x != 7) && (x <= y)
true
In C++ you can assign an expression of type int to a variable of type double with no problem.
true, Assignment from an integer type to a floating point type can lose information and should be avoided. Some compilers will warn, others may give an error message, but you should avoid this.
OOP is an acronym that means Object Oriented Programming.
true, OOP is currently popular and is a powerful programming technique for a large class of problems.