Deck 3: Expressions and Interactivity

ملء الشاشة (f)
exit full mode
سؤال
The ________ operator always follows the cin object, and the ________ operator follows the cout object.

A) input, endl
B) getChar, printChar
C) >> , <<
D) >> , >>
E) << , >>
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
________ can be used to override the rules of operator precedence.

A) Some operators
B) Parentheses
C) Operands
D) Associativity
E) Nothing
سؤال
The following pair of C++ statements is legal.
const double taxRate;
taxRate = .05;
سؤال
In any program that uses the cin object, you must #include

A) the iostream header file.
B) the fstream header file.
C) >> and << operators.
D) named constants.
E) none of the above.
سؤال
The cin object can be used to input more than one value in a single statement.
سؤال
Which of the following statements doubles the value stored in answer?

A) answer += 2;
B) answer *= 2;
C) answer = answer * 2;
D) All three of the above
E) Both B and C, but not A
سؤال
When the final value of an expression is assigned to a variable, it will be converted to

A) the smallest possible data type.
B) the largest possible data type.
C) the data type of the variable.
D) the data type of the expression.
E) none of the above.
سؤال
________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A) An input device
B) The cin object
C) The cout object
D) A preprocessor
E) Nothing
سؤال
The only difference between C-strings and string objects is how they are declared and internally stored. They are used exactly the same way.
سؤال
The following two statements will assign the same value to result.
result = a + b * c;
result = b * c + a;
سؤال
Which of the following statements will assign number a value from 90 - 100.

A) number = rand() % 90 + 10;
B) number = rand() % 90 + 11;
C) number = rand() % 10 + 90;
D) number = rand() % 11 + 90;
E) None of the above.
سؤال
Which of the following expressions will evaluate to 2.5?

A) static_cast(5/2)
B) static_cast(5)/2
C) 5/static_cast(2)
D) All three of the above
E) Both B and C, but not A
سؤال
Program code that can be evaluated to a value is called a(n)

A) operation.
B) line.
C) evaluator.
D) result.
E) expression.
سؤال
The ________ stream manipulator can be used to establish a field width for the value immediately following it.

A) cin
B) setField
C) setw
D) iomanip
E) width
سؤال
The following C++ statement will assign 1.5 to the result variable.
int result = 3.0 / 2.0;
سؤال
Hand tracing a program is

A) a program design technique.
B) a program run-time testing technique.
C) a program debugging technique.
D) creating a drawing of what a program's output screen will look like.
E) none of the above.
سؤال
Which of the following will allow an entire line of text to be read into a string object, even if it contains embedded blanks?

A) getline()
B) cin >>
C) cin.get()
D) cin.ignore()
E) both A and B, but not C or D.
سؤال
In C++, a value can be raised to a power by using

A) the ^ operator.
B) the exp operator.
C) the power operator.
D) the pow function.
E) the square function.
سؤال
When an operator's operands are of different data types, such as int and double, C++ automatically converts one of them so that they are the same data type.
سؤال
To use stream manipulators, you should include the ________ header file.

A) stream
B) fstream
C) format
D) iomanip
E) iostream
سؤال
The statement cout << setw(4) << num4 << " ";

A) outputs the value of num4 rounded to 4 decimal places.
B) outputs "setw(4)" before the value in the variable num4.
C) outputs the first 4 digits of the number stored in num4.
D) outputs the value stored in num4 four times.
E) does none of above.
سؤال
The following statement sets sum1, sum2, and sum3 all to zero.
sum1 = sum2 = sum3 = 0;
سؤال
When a C++ expression is evaluated, binary operations are performed before unary operations.
سؤال
The following two expressions evaluate to the same thing:
c + a * b
c + (a * b)
سؤال
The cin object lets the user enter a string that contains embedded blanks.
سؤال
If the value of dollars is 5.0, the following statement will output 5.00 to the monitor:
cout << fixed << showpoint << setprecision(4) << dollars << endl;
سؤال
In C++, the 5 basic arithmetic operators are
addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^).
سؤال
The following 4 lines of C++ code, use strings. string firstName; // Define a string object
Char lastName[7]; // Define a C-string
FirstName = "Abraham"; // Assign a value to the string object
LastName = "Lincoln"; // Assign a value to the C-string
Which of the following statements is /are True?

A) The string object is defined incorrectly because no size is given for it.
B) The 2 string definitions are correct, but the 2 assignment statements are wrong.
C) The string object is assigned a value correctly, but the C-string is not.
D) The C-string is assigned a value correctly, but the string object is not.
E) All 4 lines of code are correct.
سؤال
Operator associativity is either left to right or

A) top to bottom.
B) front to back.
C) right to left.
D) inside to outside.
E) nothing else; it is always left to right.
سؤال
The following pair of C++ statements will cause 3.5 to be output.
double number = 7 / 2;
cout << number;
سؤال
When converting some algebraic expressions to C++, you may need to insert ________ and ________ that do not appear in the algebraic expression.

A) values, exponents
B) operators, calculations
C) operators, operands
D) operators, parentheses
E) operands, parentheses
سؤال
The following statement sets the value of total to -3.
total -= 3;
سؤال
The ________ object causes data to be input from the keyboard.

A) cin
B) cout
C) keyboard buffer
D) standard input
E) dataIn
سؤال
To use the sqrt() function, or other mathematical library functions, you must #include the ________ header file in your program.

A) iostream
B) iomanip
C) cmath
D) algebra
E) mathlib
سؤال
Which of the following statements about named constants is/are True?

A) A named constant must be initialized with a value at the time it is declared.
B) The identifier name of a named constant can only contain capital letters and underscores.
C) The initial value of a named constant, cannot be changed during the program execution.
D) All 3 of the above statements are True.
E) Statements A and C are True, but B is not.
سؤال
When an operator has two operands of different data types, C++ always converts them both to double before performing the operation.
سؤال
The cin object must be followed by

A) a single stream insertion (<<) operator.
B) one or more stream insertion operators (<<).
C) a single stream extraction (>>) operator.
D) one or more stream extraction (>>) operators.
E) no operators.
سؤال
When an arithmetic expression contains two or more different operators, such as * and +, the order in which the operations is done is determined by

A) left to right order.
B) operator precedence.
C) operator associativity.
D) the programmer.
E) the compiler.
سؤال
The following statement number = rand() % 5 + 10;
Assigns number a value in the range of

A) 5 - 10
B) 0 - 15
C) 5 - 15
D) 10 - 15
E) none of the above.
سؤال
What does the following C++ expression evaluate to?
6 - 6 / 3 + 3

A) 0
B) 3
C) 5
D) 7
E) None of the above
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Expressions and Interactivity
1
The ________ operator always follows the cin object, and the ________ operator follows the cout object.

A) input, endl
B) getChar, printChar
C) >> , <<
D) >> , >>
E) << , >>
C
2
________ can be used to override the rules of operator precedence.

A) Some operators
B) Parentheses
C) Operands
D) Associativity
E) Nothing
B
3
The following pair of C++ statements is legal.
const double taxRate;
taxRate = .05;
False
4
In any program that uses the cin object, you must #include

A) the iostream header file.
B) the fstream header file.
C) >> and << operators.
D) named constants.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
5
The cin object can be used to input more than one value in a single statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following statements doubles the value stored in answer?

A) answer += 2;
B) answer *= 2;
C) answer = answer * 2;
D) All three of the above
E) Both B and C, but not A
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
7
When the final value of an expression is assigned to a variable, it will be converted to

A) the smallest possible data type.
B) the largest possible data type.
C) the data type of the variable.
D) the data type of the expression.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
8
________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A) An input device
B) The cin object
C) The cout object
D) A preprocessor
E) Nothing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
9
The only difference between C-strings and string objects is how they are declared and internally stored. They are used exactly the same way.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
10
The following two statements will assign the same value to result.
result = a + b * c;
result = b * c + a;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following statements will assign number a value from 90 - 100.

A) number = rand() % 90 + 10;
B) number = rand() % 90 + 11;
C) number = rand() % 10 + 90;
D) number = rand() % 11 + 90;
E) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following expressions will evaluate to 2.5?

A) static_cast(5/2)
B) static_cast(5)/2
C) 5/static_cast(2)
D) All three of the above
E) Both B and C, but not A
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
13
Program code that can be evaluated to a value is called a(n)

A) operation.
B) line.
C) evaluator.
D) result.
E) expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
14
The ________ stream manipulator can be used to establish a field width for the value immediately following it.

A) cin
B) setField
C) setw
D) iomanip
E) width
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
15
The following C++ statement will assign 1.5 to the result variable.
int result = 3.0 / 2.0;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
16
Hand tracing a program is

A) a program design technique.
B) a program run-time testing technique.
C) a program debugging technique.
D) creating a drawing of what a program's output screen will look like.
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following will allow an entire line of text to be read into a string object, even if it contains embedded blanks?

A) getline()
B) cin >>
C) cin.get()
D) cin.ignore()
E) both A and B, but not C or D.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
18
In C++, a value can be raised to a power by using

A) the ^ operator.
B) the exp operator.
C) the power operator.
D) the pow function.
E) the square function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
19
When an operator's operands are of different data types, such as int and double, C++ automatically converts one of them so that they are the same data type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
20
To use stream manipulators, you should include the ________ header file.

A) stream
B) fstream
C) format
D) iomanip
E) iostream
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
21
The statement cout << setw(4) << num4 << " ";

A) outputs the value of num4 rounded to 4 decimal places.
B) outputs "setw(4)" before the value in the variable num4.
C) outputs the first 4 digits of the number stored in num4.
D) outputs the value stored in num4 four times.
E) does none of above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
22
The following statement sets sum1, sum2, and sum3 all to zero.
sum1 = sum2 = sum3 = 0;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
23
When a C++ expression is evaluated, binary operations are performed before unary operations.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
24
The following two expressions evaluate to the same thing:
c + a * b
c + (a * b)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
25
The cin object lets the user enter a string that contains embedded blanks.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
26
If the value of dollars is 5.0, the following statement will output 5.00 to the monitor:
cout << fixed << showpoint << setprecision(4) << dollars << endl;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
27
In C++, the 5 basic arithmetic operators are
addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
28
The following 4 lines of C++ code, use strings. string firstName; // Define a string object
Char lastName[7]; // Define a C-string
FirstName = "Abraham"; // Assign a value to the string object
LastName = "Lincoln"; // Assign a value to the C-string
Which of the following statements is /are True?

A) The string object is defined incorrectly because no size is given for it.
B) The 2 string definitions are correct, but the 2 assignment statements are wrong.
C) The string object is assigned a value correctly, but the C-string is not.
D) The C-string is assigned a value correctly, but the string object is not.
E) All 4 lines of code are correct.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
29
Operator associativity is either left to right or

A) top to bottom.
B) front to back.
C) right to left.
D) inside to outside.
E) nothing else; it is always left to right.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
30
The following pair of C++ statements will cause 3.5 to be output.
double number = 7 / 2;
cout << number;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
31
When converting some algebraic expressions to C++, you may need to insert ________ and ________ that do not appear in the algebraic expression.

A) values, exponents
B) operators, calculations
C) operators, operands
D) operators, parentheses
E) operands, parentheses
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
32
The following statement sets the value of total to -3.
total -= 3;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
33
The ________ object causes data to be input from the keyboard.

A) cin
B) cout
C) keyboard buffer
D) standard input
E) dataIn
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
34
To use the sqrt() function, or other mathematical library functions, you must #include the ________ header file in your program.

A) iostream
B) iomanip
C) cmath
D) algebra
E) mathlib
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
35
Which of the following statements about named constants is/are True?

A) A named constant must be initialized with a value at the time it is declared.
B) The identifier name of a named constant can only contain capital letters and underscores.
C) The initial value of a named constant, cannot be changed during the program execution.
D) All 3 of the above statements are True.
E) Statements A and C are True, but B is not.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
36
When an operator has two operands of different data types, C++ always converts them both to double before performing the operation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
37
The cin object must be followed by

A) a single stream insertion (<<) operator.
B) one or more stream insertion operators (<<).
C) a single stream extraction (>>) operator.
D) one or more stream extraction (>>) operators.
E) no operators.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
38
When an arithmetic expression contains two or more different operators, such as * and +, the order in which the operations is done is determined by

A) left to right order.
B) operator precedence.
C) operator associativity.
D) the programmer.
E) the compiler.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
39
The following statement number = rand() % 5 + 10;
Assigns number a value in the range of

A) 5 - 10
B) 0 - 15
C) 5 - 15
D) 10 - 15
E) none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
40
What does the following C++ expression evaluate to?
6 - 6 / 3 + 3

A) 0
B) 3
C) 5
D) 7
E) None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 40 في هذه المجموعة.