Deck 2: Introduction to C Programming

Full screen (f)
exit full mode
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;
Use Space or
up arrow
down arrow
to flip the card.
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 a compilation error?

A) Placing a space between the symbols in the <= operator.
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.
Question
Which of the following is the escape character?

A) *
B) \
C) \n
D) "
Question
Which of the following is not an arithmetic operator?

A) +
B) -
C) =
D) %
Question
The std::endl stream manipulator________.

A) inputs a newline.
B) flosses the output buffer.
C) outputs a newline and flushes the output buffer.
D) terminates the program.
Question
What is the value of result after the following C++ statements execute?
Int a, b, c, d, result;
A = 4;
B = 12; c = 37;
D = 51;
Result = d % a * c + a % b + a;

A) 119
B) 51
C) 127
D) 59
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;
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 statements 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
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 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
What will be the output after the following C++ statements have been executed?
Int a, b, c, d;
A = 4;
B = 12;
C = 37;
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
The escape sequence for a newline is:

A) \n
B) \t
C) \r
D) \a
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
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
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
Which of the following is a variable declaration statement?

A) int total;
B) #include
C) int main)
D) // first string entered by user
Question
Each of the following is a relational or equality operator except:

A) <=
B) =!
C) ==
D) >
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/21
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: Introduction to C Programming
1
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
2
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
3
Which of the following is a compilation error?

A) Placing a space between the symbols in the <= operator.
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.
D
4
Which of the following is the escape character?

A) *
B) \
C) \n
D) "
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following is not an arithmetic operator?

A) +
B) -
C) =
D) %
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
6
The std::endl stream manipulator________.

A) inputs a newline.
B) flosses the output buffer.
C) outputs a newline and flushes the output buffer.
D) terminates the program.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
7
What is the value of result after the following C++ statements execute?
Int a, b, c, d, result;
A = 4;
B = 12; c = 37;
D = 51;
Result = d % a * c + a % b + a;

A) 119
B) 51
C) 127
D) 59
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
8
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;
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
9
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 21 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following statements 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 21 flashcards in this deck.
Unlock Deck
k this deck
11
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 21 flashcards in this deck.
Unlock Deck
k this deck
12
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 21 flashcards in this deck.
Unlock Deck
k this deck
13
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 21 flashcards in this deck.
Unlock Deck
k this deck
14
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 21 flashcards in this deck.
Unlock Deck
k this deck
15
What will be the output after the following C++ statements have been executed?
Int a, b, c, d;
A = 4;
B = 12;
C = 37;
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 21 flashcards in this deck.
Unlock Deck
k this deck
16
The escape sequence for a newline is:

A) \n
B) \t
C) \r
D) \a
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
17
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 21 flashcards in this deck.
Unlock Deck
k this deck
18
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 21 flashcards in this deck.
Unlock Deck
k this deck
19
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 21 flashcards in this deck.
Unlock Deck
k this deck
20
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 21 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 21 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 21 flashcards in this deck.