Wednesday, June 3, 2009

phrase of C++

1. Select the phrase that describes the effect of each these proposed C++ statements.
A. Declare variable sum to be of type int.
B. The proposed statement has invalid syntax.
C. The statement has valid syntax, but does none of the above.
D. Print "The sum is: " followed by the value of variable sum.
E. Set variable x to 1.
F. Declare variable x to be of type int.
G. Set variable sum to 0.
H. Add variable x to variable sum and assign the result to variable sum.


ABCDEFGHint x;
ABCDEFGHx = 1;
ABCDEFGH1 = x;
ABCDEFGHint sum;
ABCDEFGH0 = sum;
ABCDEFGHsum int;
ABCDEFGHsum = 0;
ABCDEFGHsum += x;
ABCDEFGHx += x;
ABCDEFGHConsole.WriteLine( "The sum is: {0}", sum );
ABCDEFGHConsole.WriteLine( "The sum is:{0}", sum );
ABCDEFGHx int;
Points Earned: 10.0/12.0
Correct Answer(s): Declare variable sum to be of type int. : int sum;, Declare variable x to be of type int. : int x;, Set variable x to 1. : x = 1;, Set variable sum to 0. : sum = 0;, The statement has valid syntax, but does none of the above. : x += x;, The proposed statement has invalid syntax. : 0 = sum;, Add variable x to variable sum and assign the result to variable sum. : sum += x;, Print "The sum is: " followed by the value of variable sum. : Console.WriteLine( "The sum is: {0}", sum );, The proposed statement has invalid syntax. : sum int;, The proposed statement has invalid syntax. : x int;, The proposed statement has invalid syntax. : 1 = x;, The statement has valid syntax, but does none of the above. : Console.WriteLine( "The sum is:{0}", sum );




2. Select the matching word or phrase.
A. for-next
B. definite
C. loop
D. if-else
E. if-true
F. flag
G. process
H. repetition
I. sequence
J. selection
K. loop-while
L. statement
M. loop-when
N. for-loop
O. if-then


ABCDEFGHIJKLMNOThe ____ selection statement is used to execute one action when a condition is true or a different action when the condition is false.
ABCDEFGHIJKLMNOWhen it is not known in advance how many times a set of statements will be repeated, a(n) ____ value can be used to terminate the repetition.
ABCDEFGHIJKLMNORepeating a set of instructions a specific number of times is called ____ repetition.
ABCDEFGHIJKLMNOAll programs can be written in terms of three types of control structures: loop, decision and ____.
Points Earned: 4.0/4.0
Correct Answer(s): sequence : All programs can be written in terms of three types of control structures: loop, decision and ____., definite : Repeating a set of instructions a specific number of times is called ____ repetition., flag : When it is not known in advance how many times a set of statements will be repeated, a(n) ____ value can be used to terminate the repetition., if-else : The ____ selection statement is used to execute one action when a condition is true or a different action when the condition is false.




3. Select the phrase that describes the effect of each these proposed C++ statements.
A. If count is greater than 10, print "Count is greater than 10."
B. Calculate the remainder after q is divided by divisor and assign the result to q.
C. Assign the sum of x and y to z and then add 1 to x.
D. The statement has valid syntax, but does none of the above.
E. Add 1 to x and then assign the sum of x and y to z.
F. Predecrement the variable x and then subtract it from total.
G. The proposed statement has invalid syntax.


ABCDEFGq = q % divisor;
ABCDEFGx++ + y = z;
ABCDEFGz = x++ + y;
ABCDEFGif ( count > 10 ) Console.WriteLine( "Count is greater than 10." );
ABCDEFGtotal = --x;
ABCDEFGtotal -= --x;
ABCDEFGtotal = total - x;
ABCDEFGz = ++x + y;
ABCDEFGq %= divisor;
Points Earned: 9.0/9.0
Correct Answer(s): Assign the sum of x and y to z and then add 1 to x. : z = x++ + y;, The proposed statement has invalid syntax. : x++ + y = z;, Add 1 to x and then assign the sum of x and y to z. : z = ++x + y;, If count is greater than 10, print "Count is greater than 10." : if ( count > 10 ) Console.WriteLine( "Count is greater than 10." );, Predecrement the variable x and then subtract it from total. : total -= --x;, The statement has valid syntax, but does none of the above. : total = total - x;, The statement has valid syntax, but does none of the above. : total = --x;, Calculate the remainder after q is divided by divisor and assign the result to q. : q %= divisor;, Calculate the remainder after q is divided by divisor and assign the result to q. : q = q % divisor;




4. Consider each statement separately and independently. For each, assume that a has a value of 120 and x has a value of 5 before the statement is executed. What will the variables' values be after they execute?
A. a = 20, x = 6
B. a = 480, x = 4
C. a = 480, x = 5
D. a = 24, x = 4
E. a = 720, x = 6
F. The statement has invalid syntax.
G. a = 24, x = 5
H. a = 20, x = 4
I. a = 24, x = 6
J. a = 600, x = 5
K. a = 480, x = 6
L. a = 30, x = 6
M. a = 720, x = 4
N. a = 720, x = 5
O. a = 30, x = 4
P. The statement has valid syntax, but none of the above is correct. The statement has valid syntax, but none of the above is correct.
Q. a = 20, x = 5
R. a = 30, x = 5
S. a = 600, x = 4
T. a = 600, x = 6


ABCDEFGHIJKLMNOPQRSTa /= --x;
ABCDEFGHIJKLMNOPQRSTa /= x--;
ABCDEFGHIJKLMNOPQRSTa *= ++x;
ABCDEFGHIJKLMNOPQRSTa *= x;
ABCDEFGHIJKLMNOPQRSTa /= x;
ABCDEFGHIJKLMNOPQRSTa *= x++;
Points Earned: 6.0/6.0
Correct Answer(s): a = 600, x = 6 : a *= x++;, a = 24, x = 4 : a /= x--;, a = 720, x = 6 : a *= ++x;, a = 30, x = 4 : a /= --x;, a = 600, x = 5 : a *= x;, a = 24, x = 5 : a /= x;




5. Select the phrase that describes the effect of each these proposed C++ statements.
A. The statement has valid syntax, but does none of the above.
B. Multiply a and b, putting the result in c.
C. Multiply c by 5, putting the result in c.
D. Add a and b, putting the result in c.
E. Add 1 to c, putting the result in c.
F. Multiply b by a, putting the result in b.
G. The proposed statement has invalid syntax.
H. Add a to b, putting the result in b.


ABCDEFGH++c;
ABCDEFGHc = c * 5;
ABCDEFGHc += 1;
ABCDEFGHc = a * b;
ABCDEFGHc *= 5;
ABCDEFGHc = a + b
ABCDEFGH**c;
ABCDEFGHc = b + a;
ABCDEFGHb *= a;
ABCDEFGHc = c + 1;
ABCDEFGHc**;
ABCDEFGHc = b * a
ABCDEFGHc++;
ABCDEFGHb += a;
Points Earned: 13.0/14.0
Correct Answer(s): Add 1 to c, putting the result in c. : c += 1;, Add 1 to c, putting the result in c. : ++c;, Add 1 to c, putting the result in c. : c++;, Multiply c by 5, putting the result in c. : c = c * 5;, Multiply a and b, putting the result in c. : c = a * b;, The proposed statement has invalid syntax. : c = b * a, Multiply b by a, putting the result in b. : b *= a;, Multiply c by 5, putting the result in c. : c *= 5;, The proposed statement has invalid syntax. : **c;, The proposed statement has invalid syntax. : c**;, Add 1 to c, putting the result in c. : c = c + 1;, The proposed statement has invalid syntax. : c = a + b, Add a and b, putting the result in c. : c = b + a;, Add a to b, putting the result in b. : b += a;

No comments:

Post a Comment