Evaluate the following C expression, assuming: 4 * 4 + 8 - 4 / 2 the precedence of operators is +,

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Evaluate the following C expression, assuming: 4 * 4 + 8 - 4 / 2 the precedence of operators is +,

Post by answerhappygod »

Evaluate the following C expression, assuming:
4 * 4
+ 8 -
4 / 2
the precedence of operators is +, -, /, *:
____________
the precedence of operators is /, -, *, +:
____________
all operators are at the same precedence, and
associate left to right: ____________
all operators are at the same precedence, and
associate right to left: ____________
How many times does the following C code iterate:
int a = 1;
int b = 5;
while( a++ && b-- && a
<= b )
cout <<
'*';
assuming that changes in the values of
variables do not affect subsequent occurrences of those variables
in the same expression (e.g., C)? ____________
assuming that changes in the values of
variables do affect subsequent occurrences of those variables in
the same expression? ____________
How many times does the following C code iterate:
int a = 3;
int b = 3;
while( --a > 0 || --b > 0 ) //Note:
--a returns value AFTER decrementing
cout <<
'*';
with short-circuit evaluation?
____________
without short-circuit evaluation?
____________
Given the following C/C++ code:
int global = 3, val = 2;
int SideEffect( int & par ) // Note: Parameter
passed by REFERENCE
{
int temp = global;
global = par;
par = temp;
return global;
}
Evaluate the expression: SideEffect ( val ) * val
assuming Left -> Right evaluation of
operands ____________
assuming Right -> Left evaluation of
operands ____________
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply