CS 135 Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

a. Rows of alpha are numbered 0...24 and columns are numbered 0...9.

Consider the following statement: int alpha[25][10];. Which of the following statements about alpha is true? a. Rows of alpha are numbered 0...24 and columns are numbered 0...9. b. Rows of alpha are numbered 0...24 and columns are numbered 1...10. c. Rows of alpha are numbered 1...24 and columns are numbered 0...9. d. Rows of alpha are numbered 1...25 and columns are numbered 1...10.

a. Rows of alpha are numbered 0...24 and columns are numbered 0...9.

Consider the following statement: int alpha[25][10];. Which of the following statements about alpha is true? a. Rows of alpha are numbered 0...24 and columns are numbered 0...9. b. Rows of alpha are numbered 0...24 and columns are numbered 1...10. c. Rows of alpha are numbered 1...24 and columns are numbered 0...9. d. Rows of alpha are numbered 1...25 and columns are numbered 1...10.

b. cin >> circle.radius;

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.radius; circle.area = 3.14 * circle.radius * radius; b. cin >> circle.radius; c. cin >> circle.radius; circle.area = 3.14 * radius * radius; d. cin >> circle;

b. cout << bigRect.length;

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.length >> width; b. cout << bigRect.length; c. cout << bigRect; d. cout << length;

b. BCDE

Consider the following statements: string str1 = "ABCDEFGHIJKLM"; string str2; After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____". a. ABCD b. BCDE c. BCD d. CDE

b. with

Consider the following statements: string str1 = "Gone with the wind"; string str2; After the statement str2 = str1.substr(5,4); executes, the value of str2 is "____". a. Gone b. with c. the d. wind

d. person2 = person1;

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. person1 = person3; b. person2 = person4; c. person2 = person3; d. person2 = person1;

b. cin >> bigRect.length;

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. cin >> bigRect.length; c. perimeter = 2 * (length + width); d. area = length * width;

c. if (bigRect.length == smallRect.width)

Consider the following statements: struct rectangleData { double length; double width; double area; double perimeter; }; rectangleData bigRect; rectangleData smallRect; Which of the following statements is legal in C++? a. if (bigRect == smallRect) b. if (bigRect != smallRect) c. if (bigRect.length == smallRect.width) d. if (bigRect.length == width)

a. bigRect.length = 10;

Consider the following statements: struct rectangleData { double length; double width; double area; double perimeter; }; rectangleData bigRect; Which of the following statements correctly initializes the component length of bigRect? a. bigRect.length = 10; b. bigRect[0]= 10 c. bigRect = {10}; d. length[0]= 10

d. student1.ID = student3.ID;

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. student1 = student4; c. student2.ID = ID; d. student1.ID = student3.ID;

b. for (int j = 0; j < 25; j++) applianceList[j].cost = 0;

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. applianceList.cost[25] = 0; b. for (int j = 0; j < 25; j++) applianceList[j].cost = 0; c. for (int j = 1; j < 25; j++) applianceList.cost[j] = 0; d. applianceList.cost = 0;

b. supplierType

Consider the following statements: struct supplierType { string name; int supplierID; }; struct paintType { supplierType supplier; string color; string paintID; }; paintType paint; What is the data type of paint.supplier? a. string b. supplierType c. struct d. paintType

c. It is an array of structs.

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 best describes applianceList? a. It is a multidimensional array. b. It is a struct. c. It is an array of structs. d. It is a struct of arrays.

c. rectangleData myRectangle;

Consider the following struct definition: struct rectangleData { double length; double width; double area; double perimeter; }; Which of the following variable declarations is correct? a. rectangle rectangleData; b. struct rectangleData(); c. rectangleData myRectangle; d. rectangleData rectangle = new rectangleData();

a. list has 10 rows and 8 columns.

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 8 rows and 10 columns. c. list has a total of 18 components. d. list has a total of 108 components.

True

Data in a struct variable must be read one member at a time. True or False?

selection

For a list of length n, the ____________________ sort makes exactly (n(n - 1))/2 key comparisons and 3(n-1) item assignments.

c. void

Functions that do not have a return type are called ____ functions. a. zero b. null c. void d. empty

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 or False?

c. n-dimensional array

A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____. a. matrix b. vector c. n-dimensional array d. parallel array

simple

A data type is called ____________________ if variables of that type can store only one value at a time.

stub

A function ____________________ is a function that is not fully coded.

True

A function can return a value of the type struct. True or False?

False

A function cannot return the value of an enumeration type. True or False?

c. a declaration, but not a definition

A function prototype is ____. a. a definition, but not a declaration b. a declaration and a definition c. a declaration, but not a definition d. a comment line

d. the values and the length

A list has two items associated with it: ____. a. the length and the references b. the values and the references c. the indexes and the length d. the values and the length

definition

A struct is a(n) ____________________, not a declaration.

heterogeneous

A struct is typically a ____ data structure.

d. either by value or by reference

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

static

A variable for which memory remains allocated as long as the program executes is called a(n) ____________________ variable.

c. formal

A variable listed in a header is known as a(n) ____ parameter. a. actual b. local c. formal d. function

b. actual parameter

A variable or expression listed in a call to a function is called the ____. a. formal parameter b. actual parameter c. data type d. type of the function

reference

A(n) ____________________ parameter is a formal parameter that receives the location (memory address) of the corresponding actual parameter.

value

A(n) ____________________ parameter s a formal parameter that receives a copy of the content of the corresponding actual parameter.

c. 0 1 1 2 2 3

After the following statements execute, what are the contents of matrix? int matrix[3][2]; int j, k; for (j = 0; j < 3; j++) for (k = 0; k < 2; k++) matrix[j][k] = j + k; a. 0 0 1 1 2 2 b. 0 1 2 3 4 5 c. 0 1 1 2 2 3 d. 1 1 2 2 3 3

True

All components of an array are of the same data type. True or False?

False

An enumeration type can be passed as a parameter to a function only by value. True or False?

False

Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference. True of 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 or False?

a. 0 through 99

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. 0 through 999

Assume you have the following declaration double salesData[1000];. Which of the following ranges is valid for the index of the array salesData? a. 0 through 999 b. 0 through 1000 c. 1 through 1001 d. 1 through 1000

c. beta[0]

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. string

Before using the data type string, the program must include the header file ____. a. enum b. iostream c. string d. std

sales[index]

Complete the following statement so that it outputs the array sales. double sales[10]; int index; for (index = 0; index < 10; index++) cout << ____________________ << " ";

FOOTBALL <= SOCCER

Consider the declaration: enum sports {BASKETBALL, FOOTBALL, HOCKEY, BASEBALL, SOCCER}; which of the following statements is true?

c. discard = '\n'

Consider the following declaration: char charArray[51]; char discard; Assume that the input is: Hello There! How are you? What is the value of discard after the following statements execute? cin.get(charArray, 51); cin.get(discard); a. discard = ' ' (Space) b. discard = '!' c. discard = '\n' d. discard = '\0'

c. strcpy(str, "Blue Sky");

Consider the following declaration: char str[15];. Which of the following statements stores "Blue Sky" into str? a. str = "Blue Sky"; b. str[15] = "Blue Sky"; c. strcpy(str, "Blue Sky"); d. strcpy("Blue Sky");

a. int alpha[] = {3, 5, 7, 9, 11};

Consider the following declaration: int alpha[5] = {3, 5, 7, 9, 11};. Which of the following is equivalent to this statement? a. int alpha[] = {3, 5, 7, 9, 11}; b. int alpha[] = {3 5 7 9 11}; c. int alpha[5] = [3, 5, 7, 9, 11]; d. int alpha[] = (3, 5, 7, 9, 11);

b. 50

Consider the following statement: double alpha[10][5];. The number of components of alpha is ____. a. 15 b. 50 c. 100 d. 150

d. sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][3];

Given the following declaration: int j; int sum; double sale[10][7]; which of the following correctly finds the sum of the elements of the fourth column of sale? a. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][3]; b. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][4]; c. sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][4]; d. sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][3];

b. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][4];

Given the following declaration: int j; int sum; double sale[10][7]; which of the following correctly finds the sum of the elements of the fourth column of sale? a. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][3]; b. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[j][4]; c. sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][4]; d. sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[j][3];

b. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[4][j];

Given the following declaration: int j; int sum; double sale[10][7]; which of the following correctly finds the sum of the elements of the fifth row of sale? a. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[5][j]; b. sum = 0; for(j = 0; j < 7; j++) sum = sum + sale[4][j]; c. sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[5][j]; d. sum = 0; for(j = 0; j < 10; j++) sum = sum + sale[4][j];

c. int u = test(5.0, '*');

Given the following function prototype: int test(float, char); which of the following statements is valid? a. printf("%d", test(12, &)); b. printf("%d", test("12.0", '&')); c. int u = test(5.0, '*'); d. printf("%d", test('12', '&'));

b. printf("%lf", tryMe(2.0, 3.0));

Given the following function prototype: double tryMe(double, double);, which of the following statements is valid? Assume that all variables are properly declared. a. scanf("%lf", &tryMe(x)); b. printf("%lf", tryMe(2.0, 3.0)); c. printf("%lf", tryMe(tryMe(double, double), double)); d. printf("%lf", tryMe(tryMe(float, float), float));

b. printf("%d", myFunc(myFunc(7, 8), 15));

Given the following function prototype: int myFunc(int, int);, which of the following statements is valid? Assume that all variables are properly declared. a. scanf("%d", &myFunc(y)); b. printf("%d", myFunc(myFunc(7, 8), 15)); c. scanf("%d", myFunc('2', '3')); d. printf("%d", myFunc(myFunc(7), 15))

a. -1

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? printf("%d\n", strange(4, 5)); a. -1 b. 1 c. 9 d. 20

c. 7

Given the following function: int next(int x) { return (x + 1); } what is the output of the following statement? printf("%d\n", next(next(5))); a.5 b. 6 c. 7 d. 8

d. printf("%f", test(7, 14, 23));

Given the function prototype: float test(int, int, int); which of the following statements is legal? a. printf("%f", test(7, test(14, 23))); b. printf("%f", test(test(7, 14), 23)); c. printf("%f", test(14, 23)); d. printf("%f", test(7, 14, 23));

a. printf("%lf", testAlpha(5, 'A', 2));

Given the function prototype: double testAlpha(int u, char v, double t); which of the following statements is legal? a. printf("%lf", testAlpha(5, 'A', 2)); b. printf("%lf", testAlpha( int 5, char 'A', int 2)); c. printf("%lf", testAlpha('5.0', 'A', '2.0')); d. printf("%lf", testAlpha(5.0, "65", 2.0));

void

If a function needs to return more than one value, as a rule of good programming style, you shouldchange it to a(n) ____________________ function and use the appropriate reference parameters to return the values.

syntax

If a global identifier in a program has the same name as one of the global identifiers in the header file, the compiler generates a(n) ____________________ error.

reference

If a variable is passed by ____________________, then when the formal parameter changes, the actual parameter also changes.

False

If an array index goes out of bounds, the program always terminates in an error. True or False?

False

If the formal parameter list of a function is empty, the parentheses after the function name are not needed. True or False?

True

In C++, [] is called the array subscript operator. True or false?

b. typedef

In C++, ____ is a reserved word. a. deftype b. typedef c. typecc d. alias

True

In C++, a function prototype is the function heading without the body of the function. True or False?

True

In C++, namespace is a reserved word.

b. .(dot)

In C++, the ____ symbol is an operator, called the member access operator. a. :(colon) b. .(dot) c. ,(comma) d. $ (dollar sign)

a. '\0'

In C++, the null character is represented as ____. a. '\0' b. "\0" c. '0' d. "0"

True

In a two-dimensional array, the elements are arranged in a table form. True or False?

structured

In a(n) ____________________ data type, each data item is a collection of other data items.

a. first row is stored first

In row order form, the ____. a. first row is stored first b. first row is stored last c. first column is stored first d. first column is stored last

False

In structs, you access a component by using the struct name together with the relative position of the component. True or False?

300

In the following declaration, the array gamma has ____________________ components. int gamma[5][6][10];

True

No arithmetic operations are allowed on the enumeration type. True or 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 or False?

reference

Stream variables (for example, ifstream and ofstream) should be passed by ____________________ to a function.

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 or False?

c. 9

Suppose str = "ABCDEFGHI". The output of the statement cout << str.length() << endl; is ____. a. 7 b. 8 c. 9 d. 10

xyYw

Suppose str = "xyzw";. After the statement str[2] = 'Y'; The value of str is "____".

c. for (j = 0; j <= 50; j++) cout << gamma[j] << " ";

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 <= 49; j++) cout << gamma[j] << " "; b. for (j = 1; j < 50; j++) cout << gamma[j] << " "; c. for (j = 0; j <= 50; j++) cout << gamma[j] << " "; d. for (j = 0; j <= 48; j++) cout << gamma[j] << " ";

b. for (int j = 0; j <= 9; j++) cout << list[j] << " "; cout << endl;

Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the elements of list? a. for (int j = 1; j < 10; j++) cout << list[j] << " "; cout << endl; b. for (int j = 0; j <= 9; j++) cout << list[j] << " "; cout << endl; c. for (int j = 1; j < 11; j++) cout << list[j] << " "; cout << endl; d. for (int j = 1; j <= 10; j++) cout << list[j] << " "; cout << endl;

b. for (int j = 0; j <= 9; j++) cout << list[j] << " "; cout << endl;

Suppose that list is an array of 10 components of type int. Which of the following codes correctly outputs all the elements of list? a. for (int j = 1; j < 10; j++) cout << list[j] << " "; cout << endl; b. for (int j = 0; j <= 9; j++) cout << list[j] << " "; cout << endl; c. for (int j = 1; j < 11; j++) cout << list[j] << " "; cout << endl; d. for (int j = 1; j <= 10; j++) cout << list[j] << " "; cout << endl;

c. for (int j = 0; j <= 49; j++) sales[j] = 0.0;

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. abc-xyz

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

b. GM

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. FORD b. GM c. TOYOTA d. HONDA

False

T/F? A function can return a value of the type array.

False

T/F? Aggregate input/output operations are allowed on a struct variable.

signature

The ____________________ of a function consists of the function name and its formal parameter list.

base address

The ____________________ of an array is the address (that is, the memory location) of the first array component.

scope

The ____________________ of an identifier refers to where in the program an identifier is accessible (visible).

selection

The ____________________ sort algorithm finds the location of the smallest element in the unsorted portion of the list and moves it to the top of the unsorted portion of the list.

False

The array index can be any integer less than the array size. True or False?

d. members

The components of a struct are called the ____ of the struct. a. variables b. identifiers c. elements d. members

True

The data type of a variable in a return statement must match the function type. True or False?

d. string::npos

The data type string has a named constant, ____, associated with it. a. string::size b. string::size_type c. string::pos d. string::npos

twelve

The declaration char str[] = "Hello there"; declares str to be a string of ____________________ characters.

False

The execution of a return statement in a user-defined function terminates the program. True or False?

True

The following function heading in a C program is valid: int funcExp(int u, char v, float g). True or False?

True

The following is a legal C++ enumeration type: enum colorType {BLUE, GREEN, PINK, YELLOW, RED}; True or False?

False

The following return statement returns the value 10. return 10, 16; True or False?

ten

The following statement creates alpha to be a two-dimensional array with ____________________ rows. int alpha[10][25];

False

The following statement creates an anonymous type: enum {1ST, 2ND, 3RD, 4TH} places; True or False?

16

The following statements store the value ____________________ into len. int len; len = strlen("Sunny California");

range-based

The form of the for loop shown below is called a(n) ____________________ for loop. for (dataType identifier : arrayName) statements

strlen(s)

The function ____________________ returns the length of the string s, excluding the null character.

False

The function main is always compiled first, regardless of where in the program the function main is placed. True or False?

c str

The header file string contains the function ____________________,which converts a value of type string to a null-terminated character array.

d. function header

The heading of the function is also called the ____. a.title b. function signature c.function head d.function header

std

The identifiers in the system-provided header files such as iostream, cmath, and iomanip are defined in the namespace _________.

c. 13

The length of the string "Hello There. " is ____. a. 11 b. 12 c. 13 d. 14

True

The one place where C++ allows aggregate operations on arrays is the input and output of C-strings. True or False?

c. 8.0

The output of the statement: cout << pow(2.0, pow(3.0, 1.0)) << endl; is ____. a. 6.0 b. 7.0 c. 8.0 d. 9.0

a. '$'

The output of the statement: cout << tolower('$') << endl; is ____. a. '$' b. '0' c. '1' d. An error, because you cannot use tolower with '$'.

a. '$'

The output of the statement: Printf("%c\n", tolower('$'); is ____. a. '$' b. '0' c. '1' d. An error, because you cannot use tolower with '$'.

c. 8.0

The output of the statement: printf("%f\n", pow(2.0, pow(3.0, 1.0))); is ____. a. 6.0 b. 7.0 c. 8.0 d. 9.0

d. 14.0

The output of the statement: printf("%f\n", pow(3.0, 2.0) + 5); is ____. a.11.0 b.12.0 c.13.0 d.14.0

driver

The program that tests a function is called a(n) ____________________ program.

15

The statement strlen("Marylin Stewart"); returns ____________________.

c. 6

The statement: return 2 * 3 + 1, 1 + 5; returns the value____. a. 2 b. 3 c. 6 d. 7

d. 6

The statement: return 37, y, 2 * 3; returns the value____. a. 2 b. 3 c. y d. 6

b. 10

The statement: return 8, 10; returns the value____. a. 8 b. 10 c. 18 d. 80

replace(pos, n, str);

The string expression strVar.____________________ starts at index pos, replaces the next n characters of strVar with all the characters of str.

enumerators

The values in the domain of an enumeration type are called ________________.

const

The word ____________________ is used before the array declaration in a function heading to prevent the function from modifying the array.

True

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). True or False?

parallel

Two (or more) arrays are called ____________________ if their corresponding components hold related information.

b. before the definitions of all the functions

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

True

Using functions greatly enhances a program's readability because it reduces the complexity of the function main. True or False?

d. 10 8 6 4 2

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

c. 0 5 10 15 20

What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++) cout << list[j] << " "; cout << endl; a. 0 1 2 3 4 b. 0 5 10 15 c. 0 5 10 15 20 d. 5 10 15 20

d. Code results in index out-of-bounds

What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 1; j <= 5; j++) cout << list[j] << " "; cout << endl; a. 0 5 10 15 20 b. 5 10 15 20 0 c. 5 10 15 20 20 d. Code results in index out-of-bounds

c. 5

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. 5

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. 6

What value is returned by the following return statement? int x = 5; return x + 1; a. 0 b. 5 c. 6 d. 7

reference

When you attach & after the dataType in the formal parameter list of a function, the variable following that dataType becomes a(n) ____________________ parameter.

True

When you pass an array as a parameter, the base address of the actual array is passed to the formal parameter. True or False?

d. Parameter passing by reference

Which of the following aggregate operations can be executed on array variables? a. Arithmetic b. Assignment c. Function returning a value d. Parameter passing by reference

d. int alpha[4][3] = {{0,1,2}, {1,2,3}, {2,3,4}, {3,4,5}};

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. char name[8] = "William";

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

a. int funcExp(int x, float v);

Which of the following function prototypes is valid? a. int funcExp(int x, float v); b. funcExp(int x, float v){}; c. funcExp(void); d. int funcExp(x);

d. int funcTest(int, int, float);

Which of the following function prototypes is valid? a. int funcTest(int x, int y, float z){} b. funcTest(int x, int y, float){}; c. int funcTest(int, int y, float z) d. int funcTest(int, int, float);

b. Assignment

Which of the following is an allowable aggregate operation on a struct? a. Arithmetic b. Assignment c. Input/output d. Comparison

a. int alpha[25];

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

enum grades {A, B, C, D, F} studentGrade;

Which of the following statements declares the studentGrade variable?

a. struct studentType { int ID; };

Which of the following struct definitions is correct in C++? a. struct studentType { int ID; }; b. struct studentType { string name; int ID; double gpa; } c. int struct studentType { ID; } d. struct studentType { int ID = 1; };

b. Prototypes end with a semicolon, but headers do not.

Which statement below about prototypes and headers is true? a. Parameter names must be listed in the prototype, but not necessarily in the header. b. Prototypes end with a semicolon, but headers do not. c. Headers should come before prototypes. d. Headers end with a semicolon, but prototypes do not.

True

You can declare struct variables when you define a struct. True or False?

Local

____________________ identifiers are not accessible outside of the function (block).

Reference

____________________ parameters are useful in three situations: • When the value of the actual parameter needs to be changed • When you want to return more than one value from a function • When passing the address would save memory space and time relative to copying a large amount of data


संबंधित स्टडी सेट्स

PN NCLEX 6th Edition- Leadership/Triage

View Set

2.1.7 Practice Questions Linux Pro

View Set

Creative Writing Final Exam Review

View Set

BUSMHR 3200 (Noe Ch.14, Benefits)

View Set

Ch 4: Common Reproductive Issues

View Set

Cardiovascular NCLEX-PN Questions

View Set