Programming with C++ Exam 1 Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

The ________ directive causes the contents of another file to be inserted into a program.

#include

The expression 5 % 2 evaluates to

1

The expression 7 % 2 evaluates to

1

A variable of the char data type can hold a set of characters like "January". True or False?

False

Executable code is computer code that contains no errors. True or false?

False

IDE stands for internal data engine. True or False?

False

If a variable is defined as int sum; it may be written in the program code as sum or Sum, but not SUM. True or False?

False

If number is an int variable, both of the following statements will print out its value: cout << number; cout << "number"; True or False?

False

If the value of dollars is 5.0, the following statement will output 5.00 to the monitor: cout << fixed << showpoint << setprecision(4) << dollars << endl; True or False?

False

In C++, the 5 basic arithmetic operators are addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^). True or False?

False

Most modern computers can understand and execute pseudocode. True or False?

False

The cin object lets the user enter a string that contains embedded blanks. True or False?

False

The following C++ statement will assign 1.5 to the result variable. int result = 3.0 / 2.0; True or False?

False

The following is a legal C++ statement to define and initialize a variable. char firstName = "Jack"; True or False?

False

The following pair of C++ statements is legal. const double taxRate; taxRate = .05; True or False?

False

The following pair of C++ statements will cause 3.5 to be output. double number = 7 / 2; cout << number; True or False?

False

The following statement sets the value of total to -3. total -= 3; True or False?

False

The following statements both declare the variable num to be an integer. int num; INT num; True or False?

False

The following two C++ statements perform the same operation. wages = regPay + overTime; regPay + overTime = wages; True or False?

False

The only difference between C-strings and string objects is how they are declared and internally stored. They are used exactly the same way. True or False?

False

The purpose of the compiler is to convert object code into source code. True or False?

False

True/False: Once a value has been stored in a variable it cannot be changed. True or False?

False

When a C++ expression is evaluated, binary operations are performed before unary operations. True or False?

False

________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

The cin object

________ must be included in a program in order to use the cout object.

The iostream header file

Before a computer can execute a program written in a high level language, such as C++, it must be translated into object code. True or False?

True

C++ is a case-sensitive language. True or False?

True

If a new value is stored in a variable, it replaces whatever value was previously there. True or False?

True

Most of the lines in a program contain something meaningful; however, some of the lines may contain nothing at all. True or False?

True

Syntax involves rules that must be followed when writing a program. True or False?

True

The cin object can be used to input more than one value in a single statement. True or False?

True

The following statement sets sum1, sum2, and sum3 all to zero. sum1 = sum2 = sum3 = 0; True or False?

True

The following two expressions evaluate to the same thing: c + a * b c + (a * b) True or False?

True

The following two statements could be used interchangeably in a C++ program. // Program Payroll /* Program Payroll */ True or False?

True

The following two statements will assign the same value to result. result = a + b * c; result = b * c + a; True or False?

True

When an operator's operands are of different data types, such as int and double, C++ automatically converts one of them so that they are the same data type. True or False?

True

In a C++ program, two slash marks ( // ) indicate the beginning of

a comment.

What does the following C++ expression evaluate to? 6 - 6 / 3 + 3

7

What value will be assigned to the variable number by the following statement? int number = 7.8;

7

The ________ operator always follows the cin object, and the ________ operator follows the cout object.

>> , <<

#include <iostream> is an example of a(n)

preprocessor directive.

Which of the following expressions will evaluate to 2.5? static_cast<double>(5/2) static_cast<double>(5)/2 5/static_cast<double>(2)

static_cast<double>(5)/2 5/static_cast<double>(2)

The programs that control and manage the basic operations of a computer are generally referred to as

system software.

The expression 5 / 2 evaluates to

2

The expression 7 / 2 evaluates to

3

What literal(s) appear in the following C++ statement? int number = 4 + 8;

4 and 8

Which of the following statements about named constants is/are true? A named constant must be initialized with a value at the time it is declared. The identifier name of a named constant can only contain capital letters and underscores. The initial value of a named constant, cannot be changed during the program execution.

A named constant must be initialized with a value at the time it is declared. The initial value of a named constant, cannot be changed during the program execution.

Which of the following definitions will allow the variable total to hold floating-point values? float total; double total; auto total = 0.0;

All of them

Which of the following keywords is/are the names of C++ data types? short long double bool

All of them

High-level programming languages include

C++ and Java C++ and JavaScript C++ and Visual Basic

The statement cout << setw(4) << num4 << " "; outputs the value of num4 rounded to 4 decimal places. outputs "setw(4)" before the value in the variable num4. outputs the first 4 digits of the number stored in num4. outputs the value stored in num4 four times. does none of above.

Does none of the above

Which of the following is/are valid C++ identifiers? June-2010 June.2010 June_2010 2010June

June_2010

________ are data items whose values cannot change while the program is running.

Literals

________ can be used to override the rules of operator precedence.

Parentheses

________ is used in a C++ program to mark the end of a statement, or to separate items in a list.

Punctuation

The following 4 lines of C++ code, use strings. string firstName; // Define a string object char lastName[7]; // Define a C-string firstName = "Abraham"; // Assign a value to the string object lastName = "Lincoln"; // Assign a value to the C-string Which of the following statements is /are true?

The string object is assigned a value correctly, but the C-string is not.

Every C++ program must have

a function called main..

In programming terms, a group of characters inside a set of double quotation marks (" ") is called

a string literal.

An integrated development environment (IDE) normally includes

a text editor, a compiler and a debugger.

A storage location in the computer's memory that can hold a piece of data is called

a variable.

A set of well-defined steps for performing a task or solving a problem is known as

an algorithm.

In the C++ statement pay = rate * hours; the * symbol is an example of

an operator.

Which of the following statements doubles the value stored in answer? answer += 2; answer *= 2; answer = answer * 2;

answer *= 2; answer = answer * 2;

An operation that copies a value into a variable is called a(n) ________ operation.

assignment

A variable must be defined

before it can be used.

A ________ variable can hold only one of two values: true or false.

bool

The ________ object causes data to be input from the keyboard.

cin

Which of the following will cause the next output to begin on a new line?

cout << endl;

The ________ is used to display information on the computer's screen.

cout object

You must have a(n) ________ for every variable you include in a program.

definition

Which of the following is/are valid C++ identifiers? department_9 aVeryLongVariableName last-name

department_9 aVeryLongVariableName

Program code that can be evaluated to a value is called a(n)

expression.

Which of the following will allow an entire line of text to be read into a string object, even if it contains embedded blanks?

getline()

The bool data type

has only two values: true and false.

C++ is an example of a ________ programming language.

high-level

Three primary activities of a typical program are

input, processing, and output.

To use stream manipulators, you should include the ________ header file.

iomanip

Words with a special meaning that may be used only for their intended purpose are known as

keywords.

Mistakes that allow a program to run, but cause it to produce erroneous results are called

logic errors.

Which of the following statements will assign number a value from 90 - 100.

number = rand() % 11 + 90;

The cin object must be followed by

one or more stream extraction (>>) operators.

When an arithmetic expression contains two or more different operators, such as * and +, the order in which the operations is done is determined by

operator precedence.

When converting some algebraic expressions to C++, you may need to insert ________ and ________ that do not appear in the algebraic expression.

operators, parentheses

Characters or symbols that perform operations on one or more operands are

operators.

A(n) ________ is a set of instructions that tells the computer how to solve a problem.

program

Creating a program requires many steps. Three of these are

program design, writing source code, and testing.

Operator associativity is either left to right or

right to left.

A ________ is used to mark the end of a complete C++ programming statement.

semicolon

The ________ stream manipulator can be used to establish a field width for the value immediately following it.

setw

A C++ character literal is enclosed in ______ quotation marks, whereas a string literal is enclosed in ______ quotation marks.

single, double

The statements written by a programmer are called

source code.

A ________ is a complete instruction that causes the computer to perform some action.

statement

When the final value of an expression is assigned to a variable, it will be converted to

the data type of the variable.

In any program that uses the cin object, you must #include

the iostream header file.

C++ automatically places ________ at the end of a string literal.

the null terminator

In C++, a value can be raised to a power by using

the pow function.

Memory locations that can hold data are called

variables.

A variable definition always specifies the name of a variable and tells

what type of data it can hold.


Conjuntos de estudio relacionados

Chapter 32: The Building of Global Empires

View Set

Teach Yourself Complete Arabic vocabulary

View Set