Deck 2: C++ Basics

Full screen (f)
exit full mode
Question
if-else statements that are inside other if-else statements are said to be _______________.
Use Space or
up arrow
down arrow
to flip the card.
Question
Is << used for input or output? ____________
Question
Every line in a program should have a comment.
Question
It is legal to declare more than one variable in a single statement.
Question
Each time a loop body executes is known as an _______________________.
Question
The body of a while loop may never execute.
Question
The opposite of less than is greater than
Question
Variable names may begin with a number.
Question
In the following code fragment,x has the value of 3.
int x = 3;
Question
<< is called the stream ____________________ operator.
Question
The integer 0 is considered true.
Question
What is the correct conditional statement to determine if x is between 19 and 99? __________________
Question
The opposite of x >3 && x < 10)is x < 3 && x > 10)
Question
The stream that is used for input from the keyboard is called ___________.
Question
Loops are used when we need our program to make a choice between two or more things.
Question
A loop that always executes the loop body at least once is known as a _____________ loop.
Question
What is the opposite of x < 20 && x > 12)? _______________________
Question
The body of a do-while loop always executes at least once.
Question
int myValue; is called a _______________________.
Question
>> is known as the stream ____________ operator.
Question
Which of the following statements is NOT legal?

A)char ch='b';
B)char ch='0';
C)char ch=65;
D)char ch="cc";
Question
What is the value of x after the following statements?
Int x;
X = x + 30;

A)0
B)30
C)33
D)garbage
Question
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.
Question
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
Question
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
Question
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
Question
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
Question
Which of the following is a valid identifier?

A)3com
B)three_com
C)3_com
D)3-com
E)dollar$
Question
Which of the following is not a valid identifier?

A)return
B)myInt
C)myInteger
D)total3
Question
The stream that is used for output to the screen is called ___________.
Question
Another way to write the value 3452211903 is

A)3.452211903e09
B)3.452211903e-09
C)3.452211903x09
D)3452211903e09
Question
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;
Question
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
Question
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
Question
Write the loop condition to continue a while loop as long as x is negative.____________________
Question
What is the value of x after the following statements?
Int x;
X = 15 %4;

A)15
B)4
C)3
D)3.75
Question
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
Question
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
Question
When must we use braces to define the body of a contitional expression? ______________
Question
What is the value of x after the following statements?
Int x;
X = 15/4;

A)15
B)3
C)4
D)3.75
Question
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
Question
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
Question
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 3
Question
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)
Question
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
Question
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
Question
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
Question
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))
Question
Executing one or more statements one or more times is known as:

A)selection
B)iteration
C)sequence
D)algorithm
Question
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
Question
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
Question
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
Question
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
Question
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.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/54
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: C++ Basics
1
if-else statements that are inside other if-else statements are said to be _______________.
nested
2
Is << used for input or output? ____________
output
3
Every line in a program should have a comment.
False
4
It is legal to declare more than one variable in a single statement.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
5
Each time a loop body executes is known as an _______________________.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
6
The body of a while loop may never execute.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
7
The opposite of less than is greater than
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
8
Variable names may begin with a number.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
9
In the following code fragment,x has the value of 3.
int x = 3;
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
10
<< is called the stream ____________________ operator.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
11
The integer 0 is considered true.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
12
What is the correct conditional statement to determine if x is between 19 and 99? __________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
13
The opposite of x >3 && x < 10)is x < 3 && x > 10)
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
14
The stream that is used for input from the keyboard is called ___________.
Unlock Deck
Unlock for access to all 54 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 54 flashcards in this deck.
Unlock Deck
k this deck
16
A loop that always executes the loop body at least once is known as a _____________ loop.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
17
What is the opposite of x < 20 && x > 12)? _______________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
18
The body of a do-while loop always executes at least once.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
19
int myValue; is called a _______________________.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
20
>> is known as the stream ____________ operator.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
21
Which of the following statements is NOT legal?

A)char ch='b';
B)char ch='0';
C)char ch=65;
D)char ch="cc";
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
22
What is the value of x after the following statements?
Int x;
X = x + 30;

A)0
B)30
C)33
D)garbage
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
23
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 54 flashcards in this deck.
Unlock Deck
k this deck
24
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
25
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
26
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
27
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following is a valid identifier?

A)3com
B)three_com
C)3_com
D)3-com
E)dollar$
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following is not a valid identifier?

A)return
B)myInt
C)myInteger
D)total3
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
30
The stream that is used for output to the screen is called ___________.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
31
Another way to write the value 3452211903 is

A)3.452211903e09
B)3.452211903e-09
C)3.452211903x09
D)3452211903e09
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
32
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;
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
33
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
34
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
35
Write the loop condition to continue a while loop as long as x is negative.____________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
36
What is the value of x after the following statements?
Int x;
X = 15 %4;

A)15
B)4
C)3
D)3.75
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
37
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
Unlock Deck
Unlock for access to all 54 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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
39
When must we use braces to define the body of a contitional expression? ______________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
40
What is the value of x after the following statements?
Int x;
X = 15/4;

A)15
B)3
C)4
D)3.75
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
41
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
42
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
43
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 3
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
44
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)
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
45
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
46
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
47
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
48
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))
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
49
Executing one or more statements one or more times is known as:

A)selection
B)iteration
C)sequence
D)algorithm
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
50
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
51
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
52
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
53
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
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
54
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.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 54 flashcards in this deck.