CIS 150 Exam Review

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/72

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

73 Terms

1
New cards

computer stores a program while it is running

main memory

2
New cards

The purpose of a memory address is:

To identify the location of a byte in memory

3
New cards

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

algorithm

4
New cards

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

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

5
New cards

An Integrated Development Environment (IDE) typically consists of

text editor, compiler, and debugger

6
New cards

a set of rules that must be followed when constructing a program:

syntax

7
New cards

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

an operator

8
New cards

Three primary activities of a program are:

input, processing, output

9
New cards

The programming process consists of several steps, which include:

design, creation, testing debugging

10
New cards

What is the first step to writing a program?

clearly defining what the program is to do

11
New cards

Two methods used by C++ to write computer programs are:

procedural programming and object-oriented programming

12
New cards

statement that starts with a hashtag is called a ____________

preprocessor directive

13
New cards

The __________ is(are) used to display information on the computer's screen.

cout object

14
New cards

What must be included in any program that uses the cout object?

the header file iostream

15
New cards

Character constants in C++ are always enclosed in:

single quotation marks

16
New cards

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

endl or \n

17
New cards

What will the following code display?

cout << "Four\n" << "score\n";cout << "and" << "\nseven";cout << "\nyears" << " ago" << endl;

four

score

and

seven

years ago

18
New cards

What will the following code display?

cout << "Roses " << "are red";cout << "and " << "violets/n"cout << "are" << "blue" << endl;

Roses are redand violets/nareblue

19
New cards

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

variable definition

20
New cards

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

a. April2018

b. employee_number

c. _1user

d. 1user

c. _luser

21
New cards

What will the following code display?

int x = 23, y = 34, z = 45;

cout << x << y << z << endl;

233445

22
New cards

Which of the following statements correctly assigns the character?

a. letter = M

b. letter = "M";

c. letter = 'M';

d. letter = (M)

c. letter = 'M';

23
New cards

What is the value of number after the following statements execute?

int number;

number = 18 / 4;

4

24
New cards

What is the value of number after the following statements execute?

int number

;number = 18 % 4 + 2;

4

25
New cards

What is output of the following statement?

cout << 4 * (15 / (1 + 3)) << endl;

12

26
New cards

Which part of the following line is ignored by the compiler?

double userName = "janedoe"; // user's name is janedoe

a. "janedoe"

b. user's name is

c. user's name is janedoe

d. //

c. user's name is janedoe

27
New cards

Which of the following statements correctly defines a named constant named TAX_RATE that holds the value 0.075?

a. double TAX_RATE = 0.075;

b. const TAX_RATE;

double TAX_RATE = 0.075;

c. const double TAX_RATE = 0.075;

d. double TAX_RATE;

const TAX_RATE = 0.075;

c. const double TAX_RATE = 0.075;

28
New cards

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?

a. cin << length, width, height;

b. cin.get (height, width, length);

c. cin.get (length, width, height);

d. cin >> length; width; height;

c. cin.get (length, width, height);

29
New cards

__________ reads a line of input, including leading and embedded spaces, and stores it in a

getline

30
New cards

After the following code executes, what is the value of my_value if the user enters 0?

cin >> my_value;

if (my_value > 5)

my_value = my_value + 5;

else if (my_value > 2)my_value = my_value + 10;

else

my_value = my_value + 15

15

31
New cards

logical AND

The && operator used to form a compound Boolean expression

32
New cards

After the following code executes, what is the output if user enters 0?

int x = -1;

cout << "Enter a 0 or 1: ";

cin >> x;

if (x)cout << "true" << endl;

elsecout << "false" << endl;

false

33
New cards

What is assigned to the variable result given the statement below with the following assumptions: x = 10, y= 7, and x, result, and y are all int variables

result = x >= y;

1

34
New cards

If you place a semicolon after the statement:

if (x < y) what will happen?

the compiler will interpret the semicolon as a null statement

35
New cards

When a relational expression is false, it has the value:

0

36
New cards

What is the output of the following code segment?

int x = 5;

if (x = 2)

cout << "This is true!" << endl;

else

cout << "This is false!" << endl;

cout << "That's all, folks!" << endl;

This is true! That's all folks

37
New cards

What is the output of the following code segment if the user enters 90 for the score?

cout << "Enter your test score: ";

cin >> test_score;

if (test_score < 60)

cout << "You failed the test." << endl;

if (test_score > 60)

cout << "You passed the test."

else

cout << "You need to study harder next time." << endl;

You passed the test

38
New cards

What is the output of the following code segment if the user enters 23?

int number;

cout << "Enter a number: ";

cin >> number;

if (number > 0)

cout << "Hi, there!" << endl;

else

cout << "Good-bye." << endl;

Hi, there!

39
New cards

What is the value of donuts after the following statement executes?

int donuts = 10;

if (donuts = 1)

donuts = 0;

else

donuts += 2;

0

40
New cards

How would you express x is less than or equal to y?

x <= y

41
New cards

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

42
New cards

What is the value of donuts after the following statement executes?

int donuts = 10;

if (donuts != 10)

donuts = 0;

else

donuts += 2;

12

43
New cards

What is the value of result after the following code executes?

int a = 60;

int b = 15;

int result = 10;

if (a = b)

result *= 2;

20

44
New cards

If you intend to place a block of statements within an if statement, you must place __________ around the block:

curly braces { }

45
New cards

A variable, usually a bool or an int, that signals when a condition exists is known as a(n):

flag

46
New cards

This operator represents the logical OR:

| |

47
New cards

This operator takes an operand and reverses its truth or falsehood:

!

48
New cards

What is the value of the following expression?

true && false

false

49
New cards

What is the value of the following expression?

true && true

true

50
New cards

What is the value of the following expression?

true || false

true

51
New cards

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

++ and --

52
New cards

This operator increments the value of its operand and then uses the value in context.

prefix increment

53
New cards

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

loop

54
New cards

The two important parts of a while loop are the expression that is tested for a true or false value and:

a statement or block that is repeated as long as the expression is true

55
New cards

Something within a while loop must eventually cause the condition to become false or a(n) __________results

infinite loop

56
New cards

The while loop is a ______________ loop

pre-test

57
New cards

if you place a semicolon after the test expression in a while loop, it is assumed to be a(n):

null statement

58
New cards

When the increment operator precedes its operand, as ++num, the expression is in __________ mode

prefix

59
New cards

A statement that may be used to stop a loop's current iteration and begin the next one is:

continue

60
New cards

A statement that causes a loop to terminate early is a:

break

61
New cards

A variable that is regularly incremented or decremented each time a loop iterates is a:

counter

62
New cards

A special value that marks the end of a list of values is a:

sentinel

63
New cards

What will the following code display?

int number = 6;

int x = 0;

x = number--;

cout << x << endl;

6

64
New cards

What is the output of the following code segment?

n = 1;

while (n <= 5)

cout << n << ' ';

n++

1 1 ... and on forever

65
New cards

In the following statement, which operator is used first?

while (x++ < 10)

<

66
New cards

What will the following code display?

int number = 6;

number++;

cout << number << endl

7

67
New cards

What will the following code display?

int number = 6;

++number;

cout << number << endl

7

68
New cards

What will the following code display?

int number = 6;

cout << number++ << endl;

6

69
New cards

What will the following code display?

int number = 6;

cout << ++number << endl;

7

70
New cards

What will the following code display?

int number = 6;

int x = 0;

Page 13 of 13

x = --number;

cout << x << endl;

5

71
New cards

A for statement contains three expressions: initialization, test, and an:

update

72
New cards

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

initialization

73
New cards

You may define a __________ in the initialization expression of a for loop.

variable