Deck 2: C++ Basics
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/57
Play
Full screen (f)
Deck 2: C++ Basics
1
It is legal to declare more than one variable in a single statement.
True
2
Each time a loop body executes is known as an _______________________.
iteration
3
The body of a do-while loop always executes at least once.
True
4
Is << used for input or output? ____________
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
5
int myValue; is called a _______________________.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
6
if-else statements that are inside other if-else statements are said to be _______________.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
7
A loop that always executes the loop body at least once is known as a _____________ loop.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
8
>> is known as the stream ____________ operator.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
9
What is the correct conditional statement to determine if x is between 19 and 99? __________________
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
10
<< is called the stream ____________________ operator.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
11
The braces for a loop define the ____________ of the loop.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
12
What is the opposite of x < 20 && x > 12)? _______________________
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
13
Every line in a program should have a comment.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
14
The body of a while loop may never execute.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
15
Loops are used when we need our program to make a choice between two or more things.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
16
In the following code fragment, x has the value of 3.
int x = 3;
int x = 3;
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
17
The integer 0 is considered true.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
18
The opposite of less than is greater than
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
19
Variable names may begin with a number.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
20
The opposite of x >3 && x < 10) is x < 3 && x > 10)
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
21
The _______ keyword in C++11 determines the type of a variable based on the data type that the variable is set to.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
22
Another way to write the value 3452211903 is
A) 3.452211903e09
B) 3.452211903e-09
C) 3.452211903x09
D) 3452211903e09
A) 3.452211903e09
B) 3.452211903e-09
C) 3.452211903x09
D) 3452211903e09
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is a valid identifier?
A) 3com
B) three_com
C) 3_com
D) 3-com
E) dollar$
A) 3com
B) three_com
C) 3_com
D) 3-com
E) dollar$
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
24
What is the value of x after the following statements?
Int x;
X = 0;
X = x + 30;
A) 0
B) 30
C) 33
D) garbage
Int x;
X = 0;
X = x + 30;
A) 0
B) 30
C) 33
D) garbage
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
25
What is the value of x after the following statements?
Int x, y, z;
Y = 10;
Z = 3;
X = y * z + 3;
A) Garbage
B) 60
C) 30
D) 33
Int x, y, z;
Y = 10;
Z = 3;
X = y * z + 3;
A) Garbage
B) 60
C) 30
D) 33
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
26
What is the value of x after the following statements?
Float x;
X = 15/4;
A) 3.75
B) 4.0
C) 3.0
D) 60
Float x;
X = 15/4;
A) 3.75
B) 4.0
C) 3.0
D) 60
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
27
What is the value of x after the following statements?
Int x;
X = 15/4;
A) 15
B) 3
C) 4
D) 3.75
Int x;
X = 15/4;
A) 15
B) 3
C) 4
D) 3.75
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
28
What is the value of x after the following statements?
Int x;
X = x + 30;
A) 0
B) 30
C) 33
D) garbage
Int x;
X = x + 30;
A) 0
B) 30
C) 33
D) garbage
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
29
What is the output of the following code?
Cout << "This is a \\" << endl;
A) This is a
B) This is a \
C) nothing, it is a syntax error
D) This is a \ endl
Cout << "This is a \\" << endl;
A) This is a
B) This is a \
C) nothing, it is a syntax error
D) This is a \ endl
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following is not a valid identifier?
A) return
B) myInt
C) myInteger
D) total3
A) return
B) myInt
C) myInteger
D) total3
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
31
The stream that is used for output to the screen is called ___________.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
32
Write the loop condition to continue a while loop as long as x is negative. ____________________
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
33
What is the value of x after the following statements?
Int x;
X = 15 %4;
A) 15
B) 4
C) 3
D) 3.75
Int x;
X = 15 %4;
A) 15
B) 4
C) 3
D) 3.75
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
34
In a compound logical and &&) expression, the evaluation of the expression stops once one of the terms of the expression is false. This is known as ______________ evaluation.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following lines correctly reads a value from the keyboard and stores it in the variable named myFloat?
A) cin > > myFloat;
B) cin << myFloat;
C) cin >> "myFloat";
D) cin >> myFloat >> endl;
A) cin > > myFloat;
B) cin << myFloat;
C) cin >> "myFloat";
D) cin >> myFloat >> endl;
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
36
What is the output of the following code?
Float value;
Value = 33.5;
Cout << value << endl;
A) 33.5
B) 33
C) value
D) garbage
Float value;
Value = 33.5;
Cout << value << endl;
A) 33.5
B) 33
C) value
D) garbage
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
37
Which of the following statements is NOT legal?
A) char ch='b';
B) char ch='0';
C) char ch=65;
D) char ch="cc";
A) char ch='b';
B) char ch='0';
C) char ch=65;
D) char ch="cc";
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
38
What is the output of the following code?
Float value;
Value = 33.5;
Cout << "value" << endl;
A) 33.5
B) 33
C) value
D) garbage
Float value;
Value = 33.5;
Cout << "value" << endl;
A) 33.5
B) 33
C) value
D) garbage
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
39
The stream that is used for input from the keyboard is called ___________.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
40
When must we use braces to define the body of a contitional expression? ______________
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
41
What is the correct way to write the condition y < x < z?
A) y < x < z)
B) y < x) && z)
C) y > x) || y < z))
D) y < x) && x < z))
A) y < x < z)
B) y < x) && z)
C) y > x) || y < z))
D) y < x) && x < z))
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
42
If x has the value of 3, y has the value of -2, and w is 10, is the following condition true or false?
If x < 2 && w < y)
A) true
B) false
If x < 2 && w < y)
A) true
B) false
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
43
What is the value of x after the following statement?
Float x;
X = 3.0 / 4.0 + 3 + 2 )/ 5
A) 5.75
B) 5.75
C) 1.75
D) 3.75
Float x;
X = 3.0 / 4.0 + 3 + 2 )/ 5
A) 5.75
B) 5.75
C) 1.75
D) 3.75
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
44
Given the following code fragment, what is the final value of y?
Int x, y;
X = -1;
Y = 0;
Whilex < 3)
{
Y += 2;
X += 1;
}
A) 2
B) 10
C) 6
D) 8
Int x, y;
X = -1;
Y = 0;
Whilex < 3)
{
Y += 2;
X += 1;
}
A) 2
B) 10
C) 6
D) 8
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
45
What is the value of x after the following statements?
Double x;
X = 0;
X += 3.0 * 4.0;
X -= 2.0;
A) 22.0
B) 12.0
C) 10.0
D) 14.0
Double x;
X = 0;
X += 3.0 * 4.0;
X -= 2.0;
A) 22.0
B) 12.0
C) 10.0
D) 14.0
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
46
Given the following code fragment, and an input value of 5, what is the output?
Int x;
If x< 3)
{
Cout << "small\n";
}
Else
{
If x < 4)
{
Cout << "medium\n";
}
Else
{
If x < 6)
{
Cout << "large\n";
}
Else
{
Cout << "giant\n";
}
}
}
A) small
B) medium
C) large
D) giant
Int x;
If x< 3)
{
Cout << "small\n";
}
Else
{
If x < 4)
{
Cout << "medium\n";
}
Else
{
If x < 6)
{
Cout << "large\n";
}
Else
{
Cout << "giant\n";
}
}
}
A) small
B) medium
C) large
D) giant
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
47
What is the value of x after the following statement?
Float x;
X = 3.0 / 4.0 + 3 + 2 / 5
A) 5.75
B) 5.75
C) 1.75
D) 3.75
Float x;
X = 3.0 / 4.0 + 3 + 2 / 5
A) 5.75
B) 5.75
C) 1.75
D) 3.75
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
48
Given the following code fragment, what is the output?
Int x=5;
If x > 5)
Cout << "x is bigger than 5. ";
Cout <<"That is all. ";
Cout << "Goodbye\n";
A) x is bigger than 5. That is all
B) x is bigger than 5
C) That is all. Goodbye
D) Goodbye
Int x=5;
If x > 5)
Cout << "x is bigger than 5. ";
Cout <<"That is all. ";
Cout << "Goodbye\n";
A) x is bigger than 5. That is all
B) x is bigger than 5
C) That is all. Goodbye
D) Goodbye
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
49
Given the following code fragment, and an input value of 3, what is the output that is generated?
Int x;
Cout <<"Enter a value\n";
Cin >> x;
Ifx=0)
{
Cout << "x is zero\n";
}
Else
{
Cout << "x is not zero\n";
}
A) x is zero
B) x is not zero
C) unable to determine
D) x is 1
Int x;
Cout <<"Enter a value\n";
Cin >> x;
Ifx=0)
{
Cout << "x is zero\n";
}
Else
{
Cout << "x is not zero\n";
}
A) x is zero
B) x is not zero
C) unable to determine
D) x is 1
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
50
Given the following code fragment and the input value of 2.0, what output is generated?
Float tax;
Float total;
Cout << "enter the cost of the item\n";
Cin >> total;
If total >= 3.0)
{
Tax = 0.10;
Cout << total + total * tax) << endl;
}
Else
{
Cout << total << endl;
}
A) 2.2
B) 2.0
C) 3.1
D) 4.4
Float tax;
Float total;
Cout << "enter the cost of the item\n";
Cin >> total;
If total >= 3.0)
{
Tax = 0.10;
Cout << total + total * tax) << endl;
}
Else
{
Cout << total << endl;
}
A) 2.2
B) 2.0
C) 3.1
D) 4.4
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
51
What is the final value of x after the following fragment of code executes?
Int x=0;
Do
{
X++;
}whilex > 0);
A) 8
B) 9
C) 10
D) 11
E) infinite loop.
Int x=0;
Do
{
X++;
}whilex > 0);
A) 8
B) 9
C) 10
D) 11
E) infinite loop.
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
52
Given the following code fragment, what is the final value of y?
Int x, y;
X = -1;
Y = 0;
Whilex <= 3)
{
Y += 2;
X += 1;
}
A) 2
B) 10
C) 6
D) 8
Int x, y;
X = -1;
Y = 0;
Whilex <= 3)
{
Y += 2;
X += 1;
}
A) 2
B) 10
C) 6
D) 8
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
53
Executing one or more statements one or more times is known as:
A) selection
B) iteration
C) sequence
D) algorithm
A) selection
B) iteration
C) sequence
D) algorithm
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
54
What is the output of the following code fragment?
Int x=0;
While x < 5)
Cout << x << endl;
X ++;
Cout << x << endl;
A) 0
B) 5
C) 4
D) unable to determine
Int x=0;
While x < 5)
Cout << x << endl;
X ++;
Cout << x << endl;
A) 0
B) 5
C) 4
D) unable to determine
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
55
Given the following code fragment, which of the following expressions is always true?
Int x;
Cin >> x;
A) if x < 3)
B) if x==1)
C) if x / 3) >1 )
D) if x = 1)
Int x;
Cin >> x;
A) if x < 3)
B) if x==1)
C) if x / 3) >1 )
D) if x = 1)
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
56
Given the following code fragment and the input value of 4.0, what output is generated?
Float tax;
Float total;
Cout << "enter the cost of the item\n";
Cin >> total;
If total >= 3.0)
{
Tax = 0.10;
Cout << total + total * tax) << endl;
}
Else
{
Cout << total << endl;
}
A) 3
B) 3.3
C) 4.0
D) 4.4
Float tax;
Float total;
Cout << "enter the cost of the item\n";
Cin >> total;
If total >= 3.0)
{
Tax = 0.10;
Cout << total + total * tax) << endl;
}
Else
{
Cout << total << endl;
}
A) 3
B) 3.3
C) 4.0
D) 4.4
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck
57
What is the advantage of the C++11 integer data types over the old data types?
A) Number of bits allocated changes dynamically as needed
B) No advantage, just new names
C) Specifies exact size in bits
D) Higher precision
A) Number of bits allocated changes dynamically as needed
B) No advantage, just new names
C) Specifies exact size in bits
D) Higher precision
Unlock Deck
Unlock for access to all 57 flashcards in this deck.
Unlock Deck
k this deck