COP 1334 Midterm

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

This is a complete instruction that causes the computer to perform some action. Line Statement Variable Key Word None of these

statement

The first step in using the string class is to #include the ________ header file. iostream cctype cmath string None of these

string

This is a set of rules that must be followed when constructing a program. Syntax Punctuation Portability Operators Key words

syntax

An example of a secondary storage device is: The computer's main memory The keyboard The monitor The disk drive None of these

the disk drive

A variable declaration announces the name of a variable that will be used in a program, as well as: The type of data it will be used to hold The operators that will be used on it The number of times it will be used in the program The area of the code in which it will be used None of these

the type of data it will be used to hold

Which escape sequence causes the cursor to move to the beginning of the CURRENT line? \n \t \a \b \r

\r

The programmer usually enters source code into a computer using: Pseudocode A text editor A hierarchy chart A compiler None of these

a text editor

An Integrated Development Environment typically consists of: A text editor A compiler A debugger All of these None of these

all of these

Which of the following is a common input device? Keyboard Mouse Scanner Microphone All of these

all of these

Of the following, which is a valid C++ identifier? June1997 _employee_number ___department myExtraLongVariableName All of these are valid identifiers.

all of these are valid identifiers

In C++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value. auto key word #include preprocessor directive variable's name dynamic_cast key word None of these

auto keyword

The ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed. Output stream cin object cout object Preprocessor None of these

cin object

This statement will pause the screen, until the [Enter] key is pressed. cin; cin.getline(); cin.get(); cin.ignore(); cin.input();

cin;

For every opening brace in a C++ program, there must be a: String literal Function Variable Closing brace None of these

closing brace

When using the sqrt function you must include this header file. cstdlib cmath cstring iostream iomanip

cmath

________ are used to translate each source code instruction into the appropriate machine language instruction. Modules Library routines Compilers Preprocessor directives None of these

compilers

Which of the following defines a double-precision floating point variable named payCheck? float payCheck; double payCheck; payCheck double; Double payCheck;

double payCheck;

Three primary activities of a program are: Variables, Operators, and Key Words Lines, Statements, and Punctuation Input, Processing, and Output Integer, Floating-point and Character None of these

input, processing, output

The numeric data types in C++ can be broken into two general categories: numbers and characters singles and doubles integer and floating point real and unreal None of these

integer and floating point

In any program that uses the cin object, you must include the ________. compiler iostream header file linker >> and << operators None of these

iostream header file

Words that have a special meaning and may be used only for their intended purpose are known as: Operators Programmer Defined Words Key Words Syntax None of these

key words

Assume that a program has the following variable definition: char letter; Which of the following statements correctly assigns the character Z to the variable? letter = Z; letter = "Z"; letter = 'Z'; letter = (Z);

letter = 'Z';

Mistakes that cause a running program to produce incorrect results are called: Syntax errors Logic errors Compiler errors Linker errors None of these

logic errors

Assume that a program has the following string object definition: string name; Which of the following statements correctly assigns a string literal to the string object? name = Jane; name = "Jane"; name = 'Jane'; name = (Jane);

name = "Jane";

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4); .3 0 .275229 3.3 None of these

0

What will the following code display? int x = 0, y = 1, z = 2; cout << x << y << z << endl; 0 1 2 0 1 2 xyz 012

012

What will the value of x be after the following statements execute? int x = 0; int y = 5; int z = 4; x = y + z * 2; 13 18 0 unknown

13

What is the value of number after the following statements execute? int number = 10; number += 5; number -= 2; number *= 3; 3 30 15 2

15

The ________ operator always follows the cin object, and the ________ operator follows the cout object. binary, unary conditional, binary >>, << <<, >> None of these

>>, <<

Which is true about the following statement? cout << setw(4) << num4 << " "; It allows four spaces for the value in the variable num4. It outputs "setw(4)" before the value in the variable num4. It should use setw(10) to output the value in the variable num10. It inputs up to four characters stored in the variable num4. None of these

It allows four spaces for the value in the variable num4.

True/False: If you do not follow a consistent programming style, your programs will generate compiler errors.

false

True/False: If you want to know the length of the string that is stored in a string object, you can call the object's size member function.

false

True/False: Machine language is an example of a high-level language.

false

True/False: The C++ language requires that you give variables names that indicate what the variables are used for.

false

True/False: The fixed manipulator causes a number to be displayed in scientific notation.

false

True/False: The following statement will output $5.00 to the screen: cout << setw(5) << dollars << endl;

false

True/False: The preprocessor executes after the compiler.

false

What will the following code display? cout << "Four\n" << "score\n"; cout << "and" << "\nseven"; cout << "\nyears" << " ago" << endl; Four score and seven years ago Four score and seven years ago Four score and seven years ago Four score and seven years ago

four score and seven years ago

________ reads a line of input, including leading and embedded spaces, and stores it in a string object. cin.get getline cin.getline get None of these

getline

If you use a C++ key word as an identifier, your program will: Execute with unpredictable results not compile understand the difference and run without problems Compile, link, but not execute None of these

not compile

In memory, C++ automatically places a ________ at the end of string literals. Semicolon Quotation marks Null terminator Newline escape sequence None of these

null terminator

Which statement is equivalent to the following? number += 1; number = number + 1; number + 1; number = 1; None of these

number = number + 1;

A(n) ________ is the most fundamental set of programs on a computer. compiler operating system application utility program None of these

operating system

Characters or symbols that perform operations on one or more operands are: Syntax Op codes Operators Program ops None of these

operators

When a variable is assigned a number that is too large for its data type, it: underflows overflows reverses polarity exceeds expectations None of these

overflows

Which of the following is not one of the five major components of a computer system? Preprocessor The CPU (central processing unit) Main memory Input/Output device Secondary storage device

preprocessor

A statement that starts with a # symbol is called a: Comment Function Preprocessor directive Key word None of these

preprocessors directive

This is used in a program to mark the beginning or ending of a statement, or separate items in a list. Separators Punctuation Operators Key Words None of these

punctuation

True/False: A CPU really only understands instructions that are written in machine language

true

The statement: cin >> setw(10) >> str; will read up to this many characters into str. Nine Ten Eleven Eight None of these

nine

Which of the following best describes an operator? An operator is a rule that must be followed when constructing a program. An operator allows you to perform operations on one or more pieces of data. An operator marks the beginning or ending of a statement, or is used to separate items in a list. An operator is a word that has a special meaning. An operator is a symbolic name that refers to a variable.

An operator allows you to perform operations on one or more pieces of data.

This is used to mark the end of a complete C++ programming statement. Pound Sign Semicolon Data type Void None of these

semicolon

A character literal is enclosed in ________ quotation marks, whereas a string literal is enclosed in ________ quotation marks. double, single triple, double open, closed single, double None of these

single, double

This function in C++ allows you to identify how many bytes of storage on your computer system an integer data value requires. len bytes f(x) int sizeof

sizeof

The statements written by the programmer are called: Syntax Object code Source code Runtime libraries None of these

source code

True/False: Escape sequences are always stored internally as a single character.

true

True/False: Floating point constants are normally stored in memory as doubles.

true

True/False: In C++, key words are written in all lowercase letters.

true

True/False: The CPU is the most important component in a computer because without it, the computer could not run software.

true

True/False: The cin << statement will stop reading input when it encounters a newline character.

true

True/False: When C++ is working with an operator, it strives to convert the operands to the same type.

true

True/False: When writing long integer literals or long long integer literals in C++ 11, you can use either an uppercase or lowercase L.

true

Programmer-defined names of memory locations that may hold data are: Operators Variables Syntax Operands None of these

variables

Look at the following program and answer the question that follows it. // This program displays my gross wages. // I worked 40 hours and I make $20.00 per hour. #include <iostream> using namespace std; int main () { int hours; double payRate, grossPay; hours = 40; payRate = 20.0; grossPay = hours * payRate; cout << "My gross pay is $" << grossPay << endl; return 0; } 13 and 14 8 and 9 14 13 15

14

What will the value of result be after the following statement executes? result = 6 - 3 * 2 + 7 - 10 / 2; 8 6 1.5 2

2

In the following C++ statement, what will be executed first according to the order of precedence? result = 6 - 3 * 2 + 7 - 10 / 2; 6 - 3 3 * 2 2 + 7 7 - 10 10 / 2

3 * 2

What is the value of average after the following code executes? double average; average = 1.0 + 2.0 + 3.0 / 3.0; 2.0 4.0 1.5 6.0

4.0

Which line in the following program will cause a compiler error? #include <iostream> using namespace std; int main () { const int MY_VAL; MY_VAL = 77; cout << MY_VAL << endl; return 0; } 6 8 9 7

6

What statement best describes a variable and its primary purpose? A variable is a structured, general-purpose language designed primarily for teaching programming. A variable is a collection of eight bits. A variable is a word that has a special meaning to the compiler. A variable is a named storage location in the computer's memory used for holding a piece of information. A variable is a "line" of code in the body of a program, which may change.

A variable is a named storage location in the computer's memory used for holding a piece of information.


Set pelajaran terkait

Chapter 21 Revolutions and Nation Building, 1848-1871

View Set

Foundations of Management Test #1

View Set

Massage Therapy Test - Head, Neck & Face

View Set

ACC2100-112 - Chapter 1A Smartbook

View Set

The Ultimate Subject/Verb Agreement Review

View Set

Silvestri Comprehensive Review for the NCLEX-PN® Exam, 7th Edition - Safety Flashcard Set

View Set

CHAPTER 13 - APPRAISAL/PROPERTY VALUATION

View Set

Chapter 49: Immunologic Agents PrepU

View Set