State which of the following are true and which are false. If false, explain your answers.
a) C++ operators are evaluated from left to right.
b) The following are all valid variable names: _under_bar_, m928134, t5, j7, her_sales, his_account_total, a, b, c, z, z2.
c) The statement cout << "a = 5;"; is a typical example of an assignment statement.
d) A valid C++ arithmetic expression with no parentheses is evaluated from left to right.
e) The following are all invalid variable names: 3g, 87, 67h2, h22, 2h.
Solution:
a) false
Precedence of arithmetic operators.
( ) Parentheses Evaluated first.
*, /, % Multiplication, Division, Modulus Evaluated second.
+- Addition Subtraction Evaluated last. b) true
c) false. typical is int a = 5;
d) true
e) false. "h22" is valid.
a) C++ operators are evaluated from left to right.
b) The following are all valid variable names: _under_bar_, m928134, t5, j7, her_sales, his_account_total, a, b, c, z, z2.
c) The statement cout << "a = 5;"; is a typical example of an assignment statement.
d) A valid C++ arithmetic expression with no parentheses is evaluated from left to right.
e) The following are all invalid variable names: 3g, 87, 67h2, h22, 2h.
Solution:
a) false
Precedence of arithmetic operators.
( ) Parentheses Evaluated first.
*, /, % Multiplication, Division, Modulus Evaluated second.
+- Addition Subtraction Evaluated last. b) true
c) false. typical is int a = 5;
d) true
e) false. "h22" is valid.
Post A Comment:
0 comments: