Programming Exam 1

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is the output of the following statement? cout << 4 * (15 / (1 + 3)) << endl;

12

This step will uncover any syntax errors in your program.

Compiling

___________reads a line of input, including leading and embedded spaces, and stores it in a string object.

getline

A variable's _____ is the part of the program that has access to the variable.

scope

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

Line 6

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

012

This statement will pause the screen, until the [Enter] key is pressed.

This statement will pause the screen, until the [Enter] key is pressed.

C++ does not have a built in data type for storing strings of characters.

True

The name for a memory location that may hold data

Variable

This stream manipulator forces cout to print the digits in fixed-point notation.

fixed

Every complete C++ program must have a ______.

function named main

How would you consolidate the following declaration statements into one statement? int x = 7; int y = 16; int z = 28;

int x = 7, y = 16, z = 28;

How would you consolidate the following declaration statements into one statement? int x = 7; int y = 16; int z = 28;

int x = 7, y = 16, z = 28;

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

#include directive

When this operator is used with string operands it concatenates them, or joins them together. You Answered

+

Assume that x is an int variable. What value is assigned to x after the following assignment statement is executed? x = -3 + 4 % 6 / 5;

-3

In the C++ instruction, cookies = number % children; given the following declaration statement: int number = 38, children = 4, cookies; what is the value of cookies after the execution of the statement?

2

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

2

Arithmetic operators that share the same precedence have right to left associativity. True or False?

False

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

False

This stream manipulator forces cout to print the digits in fixed-point notation.

Fixed

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

Four score and seven years ago

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.

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

In memory, C++ automatically places a ________ at the end of string literals

Null terminator

A statement that starts with a # is called a

Preprocessor Directive

What will the following code display? int number = 7; cout << "The number is " << "number" << endl;

The number is number

The control sequence is used to skip over to the next horizontal tab stop.

\t

You want the user to enter the length, width, and height from the keyboard. Which cin statement is correctly written?

cin >> length >> width >> height;

This reads an entire line of text until the [Enter] key is pressed

cin.getline()

What is the value stored at x, given the statements: int x; x = 3 / static_cast<int>(4.5 + 6.4);

0

Associativity is either right to left or

left to right

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

3 * 2

What will the value of x be after the following statements execute? int x; x = 18/4;

4

This function tells the cin object to skip one or more characters in the keyboard buffer

cin.ignore

You must have a _____ for every variable you intend to use in a program.

definition


Ensembles d'études connexes

8.1 The Structure of Financial Markets and Financial Assets

View Set

Supply and Demand: Theory: End of Chapter

View Set

Chapter 52: Assessment of the Gastrointestinal System

View Set