CS1B Final real

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

(T/F) Given the declaration int beta[20]; the statement cout << beta[3]; outputs the third element in the array

F

(T/F) Given two variables of type int, scoreSum and numScores, and a variable of type float, scoreAvg, the following expression scoreAvg = scoreSum / numScores; would place the correct average into scoreAvg.

F

(T/F) If name1 and name2 are of type c-string and they both contain the value "Sally", the expression name1 == name2 would evaluate to true

F

(T/F) If value is a variable, then &value is the physical address of that variable in memory.

F

(T/F) In C++, "A" and 'A' are equivalent.

F

(T/F) In C++, corresponding arguments from a calling function and parameters from a called function must have the same name

F

(T/F) In C++, corresponding arguments from a calling function and parameters from a called function must have the same name.

F

(T/F) In C++, the entire array or an individual element in array cannot be returned through a return statement

F

(T/F) In a C++ expression, all addition and subtraction are performed before multiplication or division

F

(T/F) In a black box testing, we are required to understand the internal structure of the code to correctly create the test cases

F

(T/F) In a while loop, we are not required to initialize the LCV prior to entering in the loop

F

(T/F) In the statement cout << val the symbol << is called the extraction operator because it extracts a value from memory and displays it on the screen

F

(T/F) Once the program compiles it is guaranteed to execute correctly

F

(T/F) Structs can only be passed by reference

F

(T/F) Structs cannot be returned through a return statement, but an individual member can

F

(T/F) The & operator is called the indirection operator.

F

(T/F) The C++ directive #include <myheader.h> would include the user-defined header file myheader.h

F

(T/F) The following statements will declare a 10 element array of integers: int AR_SIZE = 10; int intAR[AR_SIZE];

F

(T/F) The function heading void SomeFunc(float myFloatAr[ ]) causes a compile time error because the size of the array is missing

F

(T/F) The only arithmetic operations allowed when using enumeration type variables are increment and decrement.

F

(T/F) The order in which directives and declarations appear in a header file does not matter

F

(T/F) The statement cout << "Help\n\n\nme!"; would leave three blank lines between Help and me.

F

(T/F) The statement return 3 * alpha + 5; is valid in a void function

F

(T/F) The value of the C++ expression 7 - 3 * 5 is 20

F

(T/F) Two different enumerated types can have the same value.

F

(T/F) Two different enumerated types in the same program can have the same values

F

(T/F) Using globally declared constants is as dangerous as using globally declared variables

F

(T/F) We don't have to define the datatype for each member in a struct as long as they are all of the same datatype

F

(T/F) We don't have to define the datatype for each member in a struct as long as they are all of the same datatype.

F

(T/F) We should always pass parameters by reference because it takes less overhead

F

(T/F) We should always pass parameters by reference because it takes less overhead.

F

(T/F) When a floating point value is assigned to an integer variable, the fractional part is rounded.

F

(T/F) When a two-dimensional array is passed as a parameter, the C++ compiler ignores the size of both dimensions

F

(T/F) When the result of a floating point expression is assigned to an integer variable, the fractional part is rounded

F

(T/F) When using arrays, the compiler will give you an out of bounds error if your index is not within a valid range

F

(T/F) When using cin.getline before cin >> it is essential to include a cin.get or cin.ignore for the program to properly accept input.

F

(T/F) White box testing tests the overall functionality of the code

F

(T/F) You need to #include <fstream> when using streamsize.

F

Given: void Func(int arr[ ], int size) and the following declaration in the main: int theArray[15]; which of the following is an appropriate call to Func

Func(theArray, 15);

A data type tells the compiler

What type of data will be stored in memory and how much memory needs to be allocated

When should we use a void function over a value returning function?

When we are not returning any values, When we are returning more than one value

(T/F) Given int in1,in2; float fn3; The value of in1 is 4 after the following expression is evaluated: in1 = (fn3 = (in2 = 5) * 4 / 8) * 2

T

(T/F) Given the declaration int alpha[20]; int beta[20]; statements such as beta = alpha, cin >> beta, beta = = alpha are invalid because aggregate operations are not allowed on arrays

T

(T/F) The statement if(score[id] >= 90) { letterGrade[id] = 'A'; } is an example of the use of parallel arrays

T

(T/F) A c-string is an array of characters

T

(T/F) An escape sequence can be used for formatting character strings.

T

(T/F) Array subscripts always begin at 0

T

(T/F) Both value and reference parameters can be declared in the same function heading

T

(T/F) C++ allows some aggregate operations on structs, but never on arrays

T

(T/F) C++ allows the members of a struct to be an array.

T

(T/F) Char is an integral datatype

T

(T/F) Different struct types can have the same member(field) names

T

(T/F) Elements in an array all must be the same datatype

T

(T/F) Entering a character value when a float or an int is expected will result in an infinite loop.

T

(T/F) Enumerated types simplify coding and makes code self-documenting.

T

(T/F) For Loops are pre-test loops.

T

(T/F) Given int in1,in2; float fn3; The value of in1 is 4 after the following expression is evaluated: in1 = (fn3 = (in2 = 5) * 4 / 8) *2;

T

(T/F) If a function contains a statement that changes a value parameter, only the copy of the argument is changed, not the original

T

(T/F) If a function contains a statement that changes a value parameter, only the copy of the argument is changed, not the original.

T

(T/F) If a search algorithm used to search an array is implemented as a value returning function, the return value should be the index that represents the location of the element found

T

(T/F) If name1 and name2 are of type string and they both contain the value "Sally", the expression name1 == name2 would evaluate to true

T

(T/F) If there are several items in a parameter list, the compiler matches the parameters and the arguments by their relative positions in the lists

T

(T/F) In C++, the expression 2.5 + 8.0 % 6 would produce a compile time error

T

(T/F) In C++, we use structs to define records

T

(T/F) In the declaration char userName[25]; userName stores the base address where the beginning byte of 25 contiguous bytes are located (the base address)

T

(T/F) It is considered bad practice to have function definitions in a Header file.

T

(T/F) It is considered bad practice to initialize variables in the declaration section.

T

(T/F) It is necessary to use an .ignore() when using cin with an extraction operator followed by a cin.getline()

T

(T/F) String size is dynamically allocated

T

(T/F) Structs and individual members can be returned through a return statement.

T

(T/F) Test Stubs test whether the calling function is passing the proper values for the parameters

T

(T/F) The amount of memory AND the values to be stored in that memory for constants is determined at compile time.

T

(T/F) The declaration ifstream inFile; requires the fstream directive to be included in the program

T

(T/F) The elements in an array are accessed by an index and the members of a struct are accessed by using the dot operator

T

(T/F) The following code fragment if ( code > 10) cout << "high security"; else cout << "low security"; could be rewritten as cout << (code <=10 ? "low security": "high security");

T

(T/F) The following is a valid use for a typedef: typedef float FloatArrayType[100];

T

(T/F) The name of an array is the address in memory of the first element

T

(T/F) The scope of a local identifier extends from the point of declaration to the end of the block in which it was declared

T

(T/F) The scope of a local identifier extends from the point of declaration to the end of the block in which it was declared.

T

(T/F) The size of an array is established at compile time rather than at run time

T

(T/F) The use of the C++ manipulators fixed and setprecision( ) require the header file iomanip to be included.

T

(T/F) The value of the expression 15 > x > 5 in C++ will always be false

T

(T/F) This is a valid operation for strings. str3 = str1 + str2;

T

(T/F) Typedef creates an alias for a datatype

T

(T/F) Used properly, the typedef declarations add readability to a program

T

(T/F) User-defined header files must have the .h extension

T

(T/F) Using the float value 10.0 in the statement avg = sum / 10.0; is an example of the use of a literal constant

T

(T/F) When passing parameters by reference, the address of the calling function's argument is sent to the function

T

(T/F) When using a do while loop to validate an input we should continue executing the loop based on the range of inputs that are invalid.

T

(T/F) Without the struct datatype, storing information of different types as a set of data would require the use of parallel arrays

T

(T/F) You cannot input the value of an enumeration type directly from a standard input device.

T

If a function is supposed to compute and return the average of five variables of datatype int, which is most appropriate function type?

a value returning function using value parameters

Which of the following may appear after an extraction operator ( >> )

a variable

Which of the following describes the execution of statements while certain conditions are met.

an if-then statement

What does it mean to say a class is composed of another class

attributes in one class are class types

Which data type(s) would be most appropriate to store names such as "Joe".

char

How do you access a member of a struct?

dot operator

What is the advantage of using structs?

easier to organize related data items

The following code would cause if (x > 5); { cout << "greater than five"; } cout << "\ncontinue";

no error

Given: int val, val2; // line 1 char name1[20]; // line 2 char name2[20]; // line 3 cin .getline(name1, 20); // line 4 cin.getline(name2,20); // line 5 cin >> val2; // line 6 To make the code fragment execute properly, cin.ignore (1000, '\n'); should be placed:

nowhere, it's not necessary

Parameter passage by reference is used if a parameter's data flow is

one-way, out of the function and two-way, into and out of the function

Are aggregate operations allowed on structs?

only assignments

We can avoid side effects by...

passing parameters by constant reference, passing parameters by value

Which of the following describes the execution of two or more alternative statements:

selection

Which category of datatypes includes enums?

simple

Define a struct called DvdRec that contains the title, genre, and running time.

struct DvdRec { string title; string genre; int time; };

Which category of datatypes includes arrays?

structured

If the two variables student1 and student2 were declared as struct type which had name and id as a member, then which of the following would be valid C++ statements:

student1 = student2;

The mathematical expression 1 <= x < 100 could be written in C++ as

x >=1 && x < 100 and 1 <= x && x < 100

Can structs be a return type?

yes

Can you pass structs by value or reference?

yes

(T/F) Functions should be defined above the int main()

F

Among the C++ arithmetic operators, which ones have the highest precedence

*, / , and %

What is overloading

- Defining two methods of the same name in the same class differentiating them by their signatures - Functions and operators can also be overloaded - Static-Binding (resolved at compile time)

What is overriding?

- Redefining a method that has already been defined in the parent class (using the same signature) - Dynamic-Binding (resolved at run time)

When we write functions we should...

- Write them such that they handle one specific task - Make them generic so that they can be reused - Pass by value or by constant reference if we are not returning a value through the parameter list

Given the function definition: int Mystery(float someVal) { int retVal; if(someVal > 2.0) retVal = 3 * int(someVal); else retVal = 0; return retVal; } What is the value of the integer variable anInt after the following anInt = Mystery(4.5); ?

12

Which of the following is not a valid identifier in C++?

2ndVal

What is the value of angle after execution of the following code fragment? Assume the value 5 is input for angle cin >> angle; if (angle >= 5) { angle = angle + 15; } if (angle > 2) { angle = angle + 10; }

30

(T/F) Given int nums[25]; only the subscripts less than 0 or greater than 25 would be said to be out of bounds

F

(T/F) Enumerated types simplify coding and makes code self-documenting

F

The following code segment is an implementation of: const int AR_SIZE = 5; int intArray[AR_SIZE] = { 7, 12, 6, 4, 2}; for (int i = AR_SIZE-1; i >= 1; --i) { larger = intArray[0]; index = 0; for (int j = 1 ; j <= i; ++j) { if (intArray[j] > larger) { larger = intArray[j]; index=j; } } intArray[index] = intArray[i]; intArray[i] = larger; }

Bubble Sort

C++ source files should be arranged from top to bottom as indicated here. Select the correct one. A.Preprocessor directives Declaration section int main() { executable statements return 0; } B.Preprocessor directives int main() Declaration section { executable statements return 0; } C.Declaration section Preprocessor directives int main() { executable statements return 0; } D.Preprocessor directives int main() { Declaration section executable statements return 0; } E. none of the above

D

Declare an array 100 elements of that struct called movies

DvdRec movies[100];

(T/F) Given the following declarations: int firstArray[20]; int secondArray[20] = {1,2,3,4,5}; firstArray = secondArray; will assign the values {1, 2, 3, 4, 5} to the corresponding elements in firstArray

F

(T/F) A C++ identifier may start with a digit.

F

(T/F) A binary search can always be used in place of a sequential search

F

(T/F) A compiler translates code written in machine language into C++.

F

(T/F) A variable is the name of a location in memory that contains an unchangeable value.

F

(T/F) An individual component of an array cannot be passed as an argument to a function. The entire array must be sent

F

(T/F) Arrays are always passed by reference to functions

F

(T/F) C++ does not allow any aggregate operations on structs.

F

(T/F) Elements of a two-dimensional array are accessed by the array name followed by the column address followed by the row address

F

(T/F) Enum creates an alias for a datatype

F

If an ampersand (&) is not attached to the data type of a function parameter, the corresponding argument can be:

a constant, a variable name and an expression

What is a member?

a field within the struct

How would you output the title of the 10th element in the array?

cout << movies[9].title;

If a function is supposed to search an integer array for one instance of a search item which of the following is the most appropriate function heading?

int searchIntAr(const int intAr[ ], const int AR_SIZE, int searchItem)


Set pelajaran terkait

OSCE Pertinent Positives and Negatives

View Set

74: Histology of Female Reproductive System

View Set

Chapter 13 Exam Part 2 Labels and T/F

View Set

1.3 Explain the purpose and properties of IP addressing.

View Set

CHAPTER 5 Leadership—The Integrative Variable

View Set

EKD-NRSG 2200 Unit 3 communication

View Set