Deck 2: Introduction to C Programming; Inputoutput and Operators

Full screen (f)
exit full mode
Question
Which of the following statements does not overwrite a preexisting value stored in a memory location?

A) int a;
B) number = 12;
C) y = y + 2;
D) width = length;
Use Space or
up arrow
down arrow
to flip the card.
Question
What is the value of result after the following C++ statements execute? int a{4};
Int b{12};
Int c{37};
Int d{51};
Int result{d % a * c + a % b + a};

A) 119
B) 51
C) 127
D) 59
Question
Which is the output of the following statements? std::cout << "Hello ";
Std::cout << "World";

A) Hello World
B) World Hello
C) Hello World
D) World Hello
Question
Which of the following is the escape character?

A) *
B) \
C) \n
D) "
Question
In what order would the following operators be evaluated -, *, /, +, %
Assume that if two operations have the same precedence, the one listed first will be evaluated first.

A) +, -, /, *, %
B) -, +, %, *, /
C) -, *, %, +, /
D) *, /, %, -, +
Question
What will be the output after the following C++ statements have been executed? int a{4};
Int b{12};
Int c{37};
Int d{51};
If (a < b) {
Cout << "a < b" << endl;
}
If (a > b) {
Cout << "a > b" << endl;
}
If (d <= c) {
Cout << "d <= c" << endl;
}
If (c != d) {
Cout << "c != d" << endl;
}

A) a < b c != d
B) a < b d <= c
C != d
C) a > b c != d
D) a < b c < d
A != b
Question
Which of the following does not cause a syntax error to be reported by the C++ compiler?

A) Mismatched {}.
B) Missing */ in a comment.
C) Missing ; at the end of a statement.
D) Extra blank lines.
Question
Which of the following statements could potentially change the value of number2?

A) std::cin >> number2;
B) sum = number1 + number2;
C) number1 = number2;
D) std::cout << number2;
Question
Which of the following is not an arithmetic operator?

A) +
B) -
C) =
D) %
Question
The ________ object enables a program to read data from the user.

A) std::cout.
B) std::cin.
C) std::cread.
D) std::cget.
Question
Which of the following is a variable declaration statement?

A) int total;
B) #include
C) int main()
D) // first string entered by user
Question
The std::endl stream manipulator________.

A) inputs a newline.
B) flushes the output buffer.
C) outputs a newline and flushes the output buffer.
D) terminates the program.
Question
The escape sequence for a newline is:

A) \n
B) \t
C) \r
D) \a
Question
Which of the following is not a valid C++ identifier?

A) my Value
B) _AAA1
C) width
D) m_x
Question
End-of-line comments that should be ignored by the compiler are denoted using:

A) Two forward slashes (//).
B) Three forward slashes (///).
C) A slash and a star (/*).
D) A slash and two stars (/**).
Question
Which of the following code segments prints a single line containing hello there with the words separated by a single space?

A) std::cout << "hello "; std::cout << " there";
B) std::cout << "hello" , " there";
C) std::cout << "hello"; std::cout << "there";
D) std::cout << "hello"; std::cout << " there";
Question
The assignment operator ________ assigns the value of the expression on its right to the variable on its left.

A) <-
B) ->
C) =
D) #
Question
Which of the following statements would display the phrase C++ is fun?

A) std::cout << "Thisis fun\rC++ ";
B) std::cout << '++ is fun';
C) std::cout << "\"C++ is fun\"";
D) std::cout << C++ is fun;
Question
Which of the following is not a syntax error?

A) std::cout << 'Hello world! ';
B) std::cout << "Hello world! ";
C) std::cout << "Hello world! ";
D) std::cout << Hello world!;
Question
Which of the following uses C++11's list initialization to initialize count to 0?

A) int count = 0;
B) int count[0];
C) int count(0);
D) int count{0};
Question
Each of the following is a relational or equality operator except:

A) <=
B) =!
C) ==
D) >
Question
Which of the following is a compilation error?

A) Neglecting to declare a local variable in a function before it is used.
B) Using a triple equals sign instead of a double equals sign in the condition of an if statement.
C) Omitting the left and right parentheses for the condition of an if statement.
D) All of the above.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/22
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: Introduction to C Programming; Inputoutput and Operators
1
Which of the following statements does not overwrite a preexisting value stored in a memory location?

A) int a;
B) number = 12;
C) y = y + 2;
D) width = length;
A
2
What is the value of result after the following C++ statements execute? int a{4};
Int b{12};
Int c{37};
Int d{51};
Int result{d % a * c + a % b + a};

A) 119
B) 51
C) 127
D) 59
A
3
Which is the output of the following statements? std::cout << "Hello ";
Std::cout << "World";

A) Hello World
B) World Hello
C) Hello World
D) World Hello
A
4
Which of the following is the escape character?

A) *
B) \
C) \n
D) "
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
5
In what order would the following operators be evaluated -, *, /, +, %
Assume that if two operations have the same precedence, the one listed first will be evaluated first.

A) +, -, /, *, %
B) -, +, %, *, /
C) -, *, %, +, /
D) *, /, %, -, +
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
6
What will be the output after the following C++ statements have been executed? int a{4};
Int b{12};
Int c{37};
Int d{51};
If (a < b) {
Cout << "a < b" << endl;
}
If (a > b) {
Cout << "a > b" << endl;
}
If (d <= c) {
Cout << "d <= c" << endl;
}
If (c != d) {
Cout << "c != d" << endl;
}

A) a < b c != d
B) a < b d <= c
C != d
C) a > b c != d
D) a < b c < d
A != b
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following does not cause a syntax error to be reported by the C++ compiler?

A) Mismatched {}.
B) Missing */ in a comment.
C) Missing ; at the end of a statement.
D) Extra blank lines.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements could potentially change the value of number2?

A) std::cin >> number2;
B) sum = number1 + number2;
C) number1 = number2;
D) std::cout << number2;
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following is not an arithmetic operator?

A) +
B) -
C) =
D) %
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
10
The ________ object enables a program to read data from the user.

A) std::cout.
B) std::cin.
C) std::cread.
D) std::cget.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following is a variable declaration statement?

A) int total;
B) #include
C) int main()
D) // first string entered by user
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
12
The std::endl stream manipulator________.

A) inputs a newline.
B) flushes the output buffer.
C) outputs a newline and flushes the output buffer.
D) terminates the program.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
13
The escape sequence for a newline is:

A) \n
B) \t
C) \r
D) \a
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is not a valid C++ identifier?

A) my Value
B) _AAA1
C) width
D) m_x
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
15
End-of-line comments that should be ignored by the compiler are denoted using:

A) Two forward slashes (//).
B) Three forward slashes (///).
C) A slash and a star (/*).
D) A slash and two stars (/**).
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
16
Which of the following code segments prints a single line containing hello there with the words separated by a single space?

A) std::cout << "hello "; std::cout << " there";
B) std::cout << "hello" , " there";
C) std::cout << "hello"; std::cout << "there";
D) std::cout << "hello"; std::cout << " there";
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
17
The assignment operator ________ assigns the value of the expression on its right to the variable on its left.

A) <-
B) ->
C) =
D) #
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following statements would display the phrase C++ is fun?

A) std::cout << "Thisis fun\rC++ ";
B) std::cout << '++ is fun';
C) std::cout << "\"C++ is fun\"";
D) std::cout << C++ is fun;
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is not a syntax error?

A) std::cout << 'Hello world! ';
B) std::cout << "Hello world! ";
C) std::cout << "Hello world! ";
D) std::cout << Hello world!;
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following uses C++11's list initialization to initialize count to 0?

A) int count = 0;
B) int count[0];
C) int count(0);
D) int count{0};
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
21
Each of the following is a relational or equality operator except:

A) <=
B) =!
C) ==
D) >
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
22
Which of the following is a compilation error?

A) Neglecting to declare a local variable in a function before it is used.
B) Using a triple equals sign instead of a double equals sign in the condition of an if statement.
C) Omitting the left and right parentheses for the condition of an if statement.
D) All of the above.
Unlock Deck
Unlock for access to all 22 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 22 flashcards in this deck.