Deck 4: Control Statements, Assignment, and Operators

ملء الشاشة (f)
exit full mode
سؤال
How many times will the following loop print hello? i = 1;
While (i <= 10) {
Cout << "hello";
}

A) 0.
B) 9.
C) 10.
D) An infinite number of times.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Which of the following is true of pseudocode?

A) It is executed by the computer.
B) It helps the programmer "think out" a program.
C) It includes declarations and all types of statements.
D) All of the above are false.
سؤال
In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

A) Initial state.
B) Final state.
C) Action state.
D) Transition.
سؤال
Which of the following encompasses the other three?

A) Sequence structure.
B) Repetition structure.
C) Control structure.
D) Selection structure.
سؤال
Specifying the order in which statements are to be executed in a computer program is called:

A) An algorithm.
B) Transfer of control.
C) Program control.
D) Pseudocode.
سؤال
Which operation does not take place in the following example? int x{21};
Double y{6};
Double z{14};
Y = x / z;
X = 5.5 * y;

A) Implicit conversion.
B) Promotion.
C) Explicit conversion.
D) Truncation.
سؤال
Pseudocode normally does not include:

A) Declarations.
B) Input/output.
C) Algorithms.
D) Control structures.
سؤال
The conditional operator (?:):

A) Is the only ternary operator in C++.
B) Is a unary operator.
C) Associates from left to right.
D) Accepts two operands.
سؤال
What is wrong with the following while loop? while (sum <= 1000) {
Sum = sum - 30;
}

A) The parentheses should be braces.
B) There should be a semicolon after while (sum <= 1000).
C) sum = sum - 30 should be sum = sum + 30 or else the loop may never end.
D) None of the above.
سؤال
A block:

A) Must contain exactly three statements.
B) Cannot contain declarations.
C) Is a compound statement.
D) Is represented by placing a semicolon (;) where a statement would normally be.
سؤال
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:

A) A fatal logic error.
B) A counter exception.
C) A syntax error.
D) An off-by-one error.
سؤال
An uninitialized local variable contains:

A) The value last stored in the memory location reserved for that variable.
B) No value.
C) A value of zero.
D) A randomly assigned value.
سؤال
If grade has the value of 60, what will the following code display? if (grade >= 60) {
Cout << "Passed";
}

A) nothing.
B) 60
C) Passed
D) cout << "Passed";
سؤال
The data type bool:

A) Can take on values true and false.
B) Can take on any expression as a value.
C) Can take on values -1, 0 or 1.
D) Can only be used in a selection statement.
سؤال
Which of the following is a double-selection statement?

A) if.
B) if…else.
C) do…while.
D) switch.
سؤال
What is the final value of x after performing the following operations? int x{21};
Double y{6};
Double z{14};
Y = x / z;
X = 5.5 * y;

A) 8.25.
B) 5.5.
C) 5.
D) 8.
سؤال
Which of the following statements about nested if…else statements is true?

A) An if…else statement may not be nested in another nested if…else.
B) Each if…else statement must contain only a simple condition.
C) In an if body, an inner if…else executes only if the outer if statement's condition is true.
D) The statement(s) in an inner if always execute(s) if its condition is true.
سؤال
Which of the following is a repetition structure?

A) if.
B) if…else.
C) do…while.
D) switch.
سؤال
Which of the following is not a keyword that was added to C++ in the new C++11 standard?

A) nullptr.
B) operator.
C) constexpr.
D) noexcept.
سؤال
Which of the following does not display correct if answer is equal to 7 and incorrect if answer is not equal to 7?

A) if (answer == 7) { cout << "correct";
}
Else {
Cout << "incorrect";
}
B) cout << answer == 7 ? "correct" : "incorrect";
C) cout << (answer == 7 ? "correct" : "incorrect");
D) answer == 7 ? cout << "correct" : cout << "incorrect";
سؤال
Which of the following statements initializes the unsigned int variable counter to 10?

A) unsigned int counter = 10;
B) unsigned int counter = {10};
C) unsigned int counter{10};
D) All of the above.
سؤال
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?

A) y = 5;
B) y = x++;
C) y = ++x;
D) y = x + 1
سؤال
Which of the following is true?

A) Assigning a double value to an int does not lose any data.
B) For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss.
C) For fundamental-type variables, list-initialization syntax allows narrowing conversions that could result in data loss.
D) None of the above.
سؤال
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:

A) x: 5; y: 3
B) x: 3; y: -1
C) x: 3; y: 5
D) x: 1; y: 2
سؤال
Which of the following will not increment c by 1?

A) c + 1;
B) c++;
C) ++c;
D) c += 1;
سؤال
Having a loop within a loop is known as:

A) Recursion.
B) Doubling up.
C) Nesting.
D) Stacking.
سؤال
If x initially contains the value 3, which of the following sets x to 7?

A) x ++ 4;
B) x += 4;
C) x =+ 4;
D) x + 4 = x;
سؤال
Which of the following statements is false?

A) C++ requires all variables to have a type.
B) C++ fundamental types are portable.
C) ints may be 64 bits on some machines.
D) C++ programmers frequently have to write different versions of programs for different platforms.
سؤال
Which of the following operations has the highest precedence?

A) Postincrement.
B) Multiplication.
C) Addition.
D) Assignment.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/29
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Control Statements, Assignment, and Operators
1
How many times will the following loop print hello? i = 1;
While (i <= 10) {
Cout << "hello";
}

A) 0.
B) 9.
C) 10.
D) An infinite number of times.
D
2
Which of the following is true of pseudocode?

A) It is executed by the computer.
B) It helps the programmer "think out" a program.
C) It includes declarations and all types of statements.
D) All of the above are false.
B
3
In an activity diagram for an algorithm, what does a solid circle surrounded by a hollow circle represent?

A) Initial state.
B) Final state.
C) Action state.
D) Transition.
B
4
Which of the following encompasses the other three?

A) Sequence structure.
B) Repetition structure.
C) Control structure.
D) Selection structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
5
Specifying the order in which statements are to be executed in a computer program is called:

A) An algorithm.
B) Transfer of control.
C) Program control.
D) Pseudocode.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which operation does not take place in the following example? int x{21};
Double y{6};
Double z{14};
Y = x / z;
X = 5.5 * y;

A) Implicit conversion.
B) Promotion.
C) Explicit conversion.
D) Truncation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
7
Pseudocode normally does not include:

A) Declarations.
B) Input/output.
C) Algorithms.
D) Control structures.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
8
The conditional operator (?:):

A) Is the only ternary operator in C++.
B) Is a unary operator.
C) Associates from left to right.
D) Accepts two operands.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
9
What is wrong with the following while loop? while (sum <= 1000) {
Sum = sum - 30;
}

A) The parentheses should be braces.
B) There should be a semicolon after while (sum <= 1000).
C) sum = sum - 30 should be sum = sum + 30 or else the loop may never end.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
10
A block:

A) Must contain exactly three statements.
B) Cannot contain declarations.
C) Is a compound statement.
D) Is represented by placing a semicolon (;) where a statement would normally be.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
11
Using a while loop's counter-control variable in a calculation after the loop ends often causes a common logic error called:

A) A fatal logic error.
B) A counter exception.
C) A syntax error.
D) An off-by-one error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
12
An uninitialized local variable contains:

A) The value last stored in the memory location reserved for that variable.
B) No value.
C) A value of zero.
D) A randomly assigned value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
13
If grade has the value of 60, what will the following code display? if (grade >= 60) {
Cout << "Passed";
}

A) nothing.
B) 60
C) Passed
D) cout << "Passed";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
14
The data type bool:

A) Can take on values true and false.
B) Can take on any expression as a value.
C) Can take on values -1, 0 or 1.
D) Can only be used in a selection statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following is a double-selection statement?

A) if.
B) if…else.
C) do…while.
D) switch.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
16
What is the final value of x after performing the following operations? int x{21};
Double y{6};
Double z{14};
Y = x / z;
X = 5.5 * y;

A) 8.25.
B) 5.5.
C) 5.
D) 8.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following statements about nested if…else statements is true?

A) An if…else statement may not be nested in another nested if…else.
B) Each if…else statement must contain only a simple condition.
C) In an if body, an inner if…else executes only if the outer if statement's condition is true.
D) The statement(s) in an inner if always execute(s) if its condition is true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following is a repetition structure?

A) if.
B) if…else.
C) do…while.
D) switch.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which of the following is not a keyword that was added to C++ in the new C++11 standard?

A) nullptr.
B) operator.
C) constexpr.
D) noexcept.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
20
Which of the following does not display correct if answer is equal to 7 and incorrect if answer is not equal to 7?

A) if (answer == 7) { cout << "correct";
}
Else {
Cout << "incorrect";
}
B) cout << answer == 7 ? "correct" : "incorrect";
C) cout << (answer == 7 ? "correct" : "incorrect");
D) answer == 7 ? cout << "correct" : cout << "incorrect";
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following statements initializes the unsigned int variable counter to 10?

A) unsigned int counter = 10;
B) unsigned int counter = {10};
C) unsigned int counter{10};
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
22
Assuming that x is equal to 4, which of the following statements will not result in y containing the value 5 after execution?

A) y = 5;
B) y = x++;
C) y = ++x;
D) y = x + 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
23
Which of the following is true?

A) Assigning a double value to an int does not lose any data.
B) For fundamental-type variables, list-initialization syntax prevents narrowing conversions that could result in data loss.
C) For fundamental-type variables, list-initialization syntax allows narrowing conversions that could result in data loss.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
24
Assuming that x and y are equal to 3 and 2, respectively, after the statement x -= y executes, the values of x and y will be:

A) x: 5; y: 3
B) x: 3; y: -1
C) x: 3; y: 5
D) x: 1; y: 2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which of the following will not increment c by 1?

A) c + 1;
B) c++;
C) ++c;
D) c += 1;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
26
Having a loop within a loop is known as:

A) Recursion.
B) Doubling up.
C) Nesting.
D) Stacking.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
27
If x initially contains the value 3, which of the following sets x to 7?

A) x ++ 4;
B) x += 4;
C) x =+ 4;
D) x + 4 = x;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following statements is false?

A) C++ requires all variables to have a type.
B) C++ fundamental types are portable.
C) ints may be 64 bits on some machines.
D) C++ programmers frequently have to write different versions of programs for different platforms.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following operations has the highest precedence?

A) Postincrement.
B) Multiplication.
C) Addition.
D) Assignment.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 29 في هذه المجموعة.