CSC C++

Ace your homework & exams now with Quizwiz!

The formal definition of a digit shown below is an example of the use of what metalanguage? <digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Backus-Naur Form (BNF)

What is the output of the following program fragment? cout << "Barrel" << endl; cout << ' '; cout << "of"; cout << "Laughs" << endl;

Barrel ofLaughs

The following series of steps is not an algorithm. How would you correct it? Putting on a Pair of Athletic Shoes Step 1. Put on one shoe. Step 2. Tie the laces. Step 3. Repeat.

Change step 3 to 'Repeat once.'

Of the following components of a computer, which one assures that program instructions are executed in the proper sequence?

Control Unit

Of the following components of a computer, which one fetches the next instruction from RAM during program execution?

Control unit

Which problem-solving technique involves the breaking up of a large problem into smaller units that are easier to handle?

Divide and conquer

True or False? A computer can directly execute assembly language instructions.

False

True or False? A literal string can continue onto more than one line, as long as it is enclosed in double quotes.

False

True or False? A value-returning function is always called (invoked) by using its name and argument list as a complete, stand-alone statement.

False

True or False? All algorithms can be implemented as computer programs.

False

True or False? All computer viruses are destructive to computer resources.

False

True or False? An assembler is a program that translates an assembly language program into a high-level language.

False

True or False? Backus-Naur Form (BNF) is used for documenting a means-ends analysis.

False

True or False? If a program compiles successfully, it is guaranteed to execute correctly.

False

True or False? If someFloat is a variable of type float, the statement someFloat = 395; causes someFloat to contain an integer rather than floating-point value.

False

True or False? If the int variable someInt contains the value 26, the statement cout << "someInt"; outputs the value 26.

False

True or False? In C++, the expression (a + b / c) / 2 is implicitly parenthesized as ((a + b) / c) / 2.

False

True or False? In a C++ expression without parentheses, all operations are performed in order from left to right.

False

True or False? In contrast to integer values, you cannot specify a fieldwidth for floating-point values.

False

True or False? The C++ compiler considers the identifier CanOfWorms to be the same as the identifier canofworms.

False

True or False? The most powerful class of computer available is the mainframe computer.

False

True or False? The null string (empty string with no characters) must be denoted by the special NULL symbol.

False

True or False? The setprecision manipulator is used to increase or decrease the precision of floating-point numbers that are stored in the computer's memory unit.

False

True or False? The statement const char INITIAL = 'G'; is an example of an assignment statement.

False

True or False? The statement myVar++; causes 1 to be subtracted from myVar.

False

True or False? The term software refers to the physical components of a computer.

False

True or False? The value of the expression a+b * c+d is different from the value of the expression a + b*c + d.

False

True or False? There is only one unique general solution (algorithm) for a given problem.

False

True or False? There is only one unique way to translate a given algorithm into a C++ program.

False

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

Go Home

Of the following components of a computer, which one stores data and instructions?

Memory unit

If name is a string variable, what is the output of the following code? name = "Marian"; cout << "Name: " << name.substr(1, 3) + "sta";

Name: arista

All of the following are useful software maintenance tips when modifying complex code EXCEPT

Never document your updated code changes to avoid confusion.

What is the output of the following program fragment? (alpha and beta are int variables.) alpha = 2463; beta = 72; cout << "123456789" << endl << setw(5) << alpha << endl << setw(5) << beta << endl;

None of the above

Of the following components of a computer, which one presents the results of the processing to the outside world?

Output device

Which of the following terms describes the execution of a series of statements (instructions) one after another?

Sequence

Which of the following is the second step in the implementation phase of a computer program's life cycle?

Test the solution on a computer

Which of the following statements about the C++ main function is false?

The main function must call (invokE. at least one other function

Which of the following is the first step in the implementation phase of a computer program's life cycle?

Translate the general solution into code

True or False? A C++ identifier cannot start with a digit.

True

True or False? A computer game is an example of interactive, not batch, processing.

True

True or False? A computing professional has a responsibility not to engage in software piracy and prevent it from occurring.

True

True or False? A computing professional has a responsibility to guard confidential data from unauthorized access by others.

True

True or False? A file is a named area in secondary storage that is used to hold a collection of data.

True

True or False? A program that dispenses money from an ATM (automatic teller machinE. is an example of an interactive, not batch, program.

True

True or False? A syntax diagram is a metalanguage that uses arrows to indicate how symbols can be combined.

True

True or False? A syntax template is a generic example of the C++ construct being defined.

True

True or False? A void function is always called (invoked) by using its name and argument list as a complete, stand-alone statement.

True

True or False? All computer programs are algorithms.

True

True or False? Assuming x and y are variables of type float, the expression sqrt(fabs(3.8 * x + 9.4 * y)) is a valid use of the sqrt and fabs library functions.

True

True or False? Comments should be concise and avoid crowding statements in the program.

True

True or False? Every C++ program must have a function named main.

True

True or False? Execution of the statement someInt = 3 * int(someFloat); does not change the contents of the variable someFloat in memory.

True

True or False? If myString is a string variable and the statement myString = "Harry"; is executed, then the value of the expression myString.find('r') is 2.

True

True or False? In C++, a block (compound statement) is not terminated by a semicolon.

True

True or False? In C++, the modulus operator (%) requires integer operands.

True

True or False? In C++, the value of the expression 3 + 2 * 6 is 15.

True

True or False? In a C++ floating-point constant, a decimal point is not required if exponential (E) notation is used.

True

True or False? In a computer, data is represented electronically by pulses of electricity.

True

True or False? In the 'solve by analogy' technique, you solve a problem by modifying the solution to a similar problem.

True

True or False? Integer values and floating-point values are stored differently inside the computer.

True

True or False? Magnetic tape drives and floppy disk drives are examples of auxiliary (secondary) storage devices.

True

True or False? RAM stands for random access memory.

True

True or False? Setting the fieldwidth of a data item holds only for the next consecutive item to be output. After this output, the fieldwidth resets to 0.

True

True or False? The compiler is a program that translates a high-level language program into machine code.

True

True or False? The null statement is an empty statement consisting only of a semicolon.

True

True or False? The setw manipulator is used only for formatting numeric values and strings, not char data.

True

True or False? The two components of the central processing unit (CPU) are the arithmetic/logic unit and the control unit.

True

True or False? The two manipulators, setw and setprecision, require that a computer programmer also #include the header file, iomanip.

True

True or False? The value set to setprecision remains in effect for all following output until the computer programmer changes it with another call to setprecision.

True

True or False? To use a C++ library function, you must use an #include directive to include the appropriate header file.

True

True or False? When a floating-point value is assigned to an integer variable, the fractional part is truncated.

True

Which of the following is the second step in the problem-solving phase of a computer program's life cycle?

Write a general solution for the problem

Formatting a program in a consistent, readable style is valuable to

a and b above

If testScore is an int variable containing the value 78, which output statement will produce the following output: 1234567890 Score: 78

a and b above

Of the following components of a computer, which one performs computations?

arithmetic/logic unit

Which of the following statements prints HappyBirthday on one output line?

b and c above

If x is a float variable containing a positive value, which of the following statements outputs the value of x, rounded to the nearest integer?

cout<<int(x + 0.5);

Which expression does not correctly compute the mathematical average of the int variables int1, int2, and int3?

float((int1 + int2 + int3) / 3)

Where can C++ comments appear in a computer program?

in constant and variable declarations

If DoSomething is a void function that takes an int expression as an argument, which of the following is an incorrect statement? (Assume all variables are int variables.)

length = DoSomething(width);

Which of the following terms describes the repetition of statements (instructions) while certain conditions are met?

looping

Which problem-solving technique involves defining the beginning and ending states of a problem, then comparing different methods for getting between the states?

means-ends analysis

Which problem-solving technique involves integrating existing solutions on a step-by-step basis into a complete solution?

merging solutions

Which of the following is a legal string assignment?

name = "Jones";

Which of the following terms describes the execution of different statements (instructions) depending on certain conditions?

selection

Which problem-solving technique involves recognizing that the problem you are working on is similar to one that you have worked on before?

solving by analogy

Which assignment statement could be used to store the letter A into the char variable someChar?

someChar = 'A';

One of the following statements does not show a proper use of the sqrt library function. Which one is the wrong statement? (Assume all variables are float variables.)

sqrt(25.0 * x);

In C++, the phrase "standard output device" usually refers to:

the display screen

Which one of the following is not one of the three major phases in the life cycle of a computer program?

the management phase

Which of the following is NOT an example of a computer programmer taking a step to guard confidential computer data?

utilizing malware to protect confidential computer data from being stolen.

Which one of the following is a valid "Thing"?

$@yyyy

Assuming all variables are of type float, the C++ expression for (a + b) * c / d + e is:

(a + b) * c / d + e

What is the output of the following program fragment? (x is a float variable.) x = 25.6284; cout << "**" << setw(6) << setprecision(1) << x << endl;

** 25.6

Among the C++ operators +, -, *, /, and %, which ones have the lowest precedence?

+ and -

The value of the C++ expression 3 / 4 * 5 is:

0

If the int variables int1 and int2 contain the values 4 and 5, respectively, then the value of the expression float(int1 / int2) is:

0.0

Given that x is a float variable and num is an int variable containing the value 38, what will x contain after execution of the following statement: x = num / 4 + 3.0;

12.0

The value of the C++ expression 11 + 22 % 4 is:

13

If plant is a string variable and the statement plant = "Dandelion"; is executed, then the value of the expression plant.find('d')is

3

Which one of the following is a valid 'Yoyo'?

33

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

3BlindMice

Given that x is a float variable and num is an int variable containing the value 5, what will x contain after execution of the following statement: x = num + 2;

7.0

Which of the following translates a program written in a high-level language into machine code?

A compiler

Which of the following most closely resembles human language?

A high-level language

Which of the following can be assigned to a char variable?

All of the above

Which of the following is the first step in the problem-solving phase of a computer program's life cycle?

Analyze the problem.

What is the output of the following program fragment? age = 29; cout << "Are you" << age << "years old?" << endl;

Are you29years old?

Inside a computer, a single character such as the letter A usually is represented by a:

byte


Related study sets

Anatomy Exam; (Unit 4) Central Nervous System and Peripheral Nervous System

View Set

Cerebellum and Vestibular System

View Set

Chapter 2 - Basic SQL SELECT Statements

View Set