chapter 1-5

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

These are operators that add and subtract one from their operands.

++ and --

What is the value of donuts after the following statement executes? int donuts = 10; if (donuts = 1) donuts = 0; else donuts += 2;

0

What will the following code display? int x = 0; while (x < 5) { cout << x << endl; x++; }

0 1 2 3 4

What will be displayed after the following statements execute? int funny = 7, serious = 15; funny = serious % 2; if (funny != 1) { funny = 0; serious =0; } else if (funny == 2) { funny = 10; serious = 10; } else { funny = 1; serious = 1; } cout << funny << " " << serious << endl;

1 1

To use the rand()function, you must include the ________ header file?

cstdlib

Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?

outFile << number;

This is a complete instruction that causes the computer to perform some action:

statement

In the following statement, the characters Hello! are a(n) cout << "Hello!";

string literal

If you place a semicolon after the statement: if (x < y)

the compiler will interpret the semicolon as a null statement

Which of the following must be included in any program that uses the cin object?

the header file iostream

Which of the following must be included in any program that uses the cout object?

the header file iostream

A variable definition defines 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

In a for statement, this expression is executed only once:

initialization

The numeric data types in C++ can be broken into two general categories which are

integers and floating-point numbers

Which of the following is NOT a common input device?

keyboard digital camera mouse printer

These operators connect two or more relational expressions into one, or reverse the logic of an expression.

logical

This is a control structure that causes a statement or group of statements to repeat.

loop

Which statement is equivalent to the following? number = number * 2;

number *= 2;

What is the output of the following segment of code if the value 4 is input by the user? int num; int total = 0; cout << "enter a number from 1 to 10: "; cin >> num; switch (num) { case 1: case 2: total = 5; case 3: total = 10; case 4: total = total + 3; case 8: total = total + 6: default: total = total + 4; } cout << total << endl;

13

What is the value of x after the following code executes? int x = 0; int y = 5; int z = 4; x = x + y + z * 2;

13

How many times will the following loop display " Looping again!"? for (int i = 0; i <= 20; i++) cout << "looping again" << endl;

21

What will the following code display? Int number = 6; ++number; cout << number << endl;

7

How many characters will the following statement read into the variable myString? cin >> setw(10) >> myString;

9

In the following statement, which operator is used first? while (x++ < 10)

<

In the process of translating a source file into an executable file, which of the following is the correct sequence?

Source code, preprocessor, modified source code, compiler, object code, linker, executable code.

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

The beginning of a comment

are used to translate each source code instruction into the appropriate machine language instruction.

compilers

What is the output of the following code segment if the user enters 90 for the score? cout << "enter your score: "; in >> test_score; if(test_score < 60) cout << "you failed the exam" << endl; if(tes_Score > 60) cout << "you passed the exam" << endl; else cout << "you need to study harder" << endl;

You passed the test.

Given the if/else statement: if (a < 5) b = 12; else d = 30;

a < 5 ? b = 12 : d = 30;

Input values should always be checked for

an appropriate range, reasonableness, division by zero, if division is taking place

A file ________ is a small holding section of memory that file-bound information is first written to.

buffer

Which data type typically requires only one byte of storage?

char

Which of the following will allow the user to input the values 15 and 20 and have them stored in variables named base and height, respectively?

cin >> base >> height;

Which of the following statements will allow the user to enter three values to be stored in variables length, width, and height, in that order?

cin.get(length, width, height);

For every opening brace ( {) in a C++ program, there must be a

closing brace

Relational operators allow you to ________ numbers.

compare

The programming process consists of several steps, which include:

design, creation, testing, debugging

A character literal is ________, whereas a string literal is ________

enclosed in single quotation marks, enclosed in double quotation marks

In a cout statement, which of the following will advance the output position to the beginning of the next line?

endl or \n

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

getline

Which statement allows you to properly check the char variable code to determine whether it is equal to a C and then output This is a check?

if (code == 'C') cout << "this is a check\n";

This means to increase a value:

increment

This is used in a program to mark the beginning or ending of a statement, or separate items in a list:

punctuation

Programs are normally stored in ________ and loaded into main memory as needed.

secondary storage

You can control the number of significant digits in your output with the ________ manipulator

setprecision

This manipulator is used to establish a field width for the value that follows it:

setw

Computer programs are also known as

software

When a programmer saves to a file the statements he or she writes to create a program, these statements are

source code

A variable definition tells the computer

the variable's name and the type of data it will hold

A(n) ________ represents a storage location in the computer's memory.

variable


Conjuntos de estudio relacionados

CCSK - DOMAIN 1: CLOUD COMPUTING ARCHITECTURAL FRAMEWORK

View Set

Client Server Technology Practice Quiz

View Set

Math, Chapter 8: Multiply and Divide Signed Rational Numbers.

View Set

Pharmacology Exam 3 Study Questions Set Two

View Set

Kohlberg's Stages of Moral Thought

View Set

Exercise 1: Activity 3 stimulating osmotic pressure

View Set