Deck 2: Introduction to C Programming; Inputoutput and Operators
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/22
Play
Full screen (f)
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) 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
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
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) "
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) *, /, %, -, +
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
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.
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;
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) %
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.
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
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.
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
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
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 (/**).
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";
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) #
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;
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!;
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};
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) >
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.
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