Question

Q#2 (6 points) Assume following precedence levels 1. parentheses 2. unary operators 3. **(exponentiation: if the language supports it) 6. Relational operators 7. Conditional operators 8. Boolean operators Determine the value of the following expressions, assuming a 5, b 2, c 4 and d-5. a. a5 Answer: Answer: Answer: c. b* a-b*c)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a)

In the statement

!a == 5

The code is equivalent to

(!a) == 5

(!5) == 5

0 == 5

false

(b)

The statement

b * d <= c * c

2 * 5 <= 4 * 4

10 <= 16

true

(c)

In the statement

b * c || ( a - b* c )

The statement is equivalent to

( b * c ) || ( a - ( b * c ) )

( 2 * 4 ) || ( 5 - ( 2 * 4 ) )

8 || ( 5 - 8 )

8 || -3

true

Add a comment
Know the answer?
Add Answer to:
Q#2 (6 points) Assume following precedence levels 1. parentheses 2. unary operators 3. **(exponentiation: if the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 4. Assume the following rules of associativity and precedence for expressions: Precedence Highest *, /, not...

    4. Assume the following rules of associativity and precedence for expressions: Precedence Highest *, /, not +,-,&, mod - (unary) =,/=,<,<=,>=,> and or, xor Lowest Associativity Left to right Show the order of evaluation of the following expressions by parenthesizing all sub expressions and placing a superscript on the right parenthesis to indicate order. For example, for the expression a+b*c+d the order of evaluation would be represented as ((a+(b*c)1)2 +d)3 a * b - 1 + c a * (b...

  • Assume the following rules of associativity and precedence for expressions: Precedence   Highest   *, /, not   +,...

    Assume the following rules of associativity and precedence for expressions: Precedence   Highest   *, /, not   +, -, &, mod   - (unary)   =, /=, <, <=, >=, >   and   Lowest   or, xor Associativity   Left to right Show the order of evaluation of the following expressions by parenthesizing all subexpressions and placing a superscript on the right parenthesis to indicate order. For example, for the expression a + b * c + d the order of evaluation would be represented as ((a...

  • 1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming...

    1. (p. 2-3.) Which of the following is NOT a reason for studying concepts of programming languages according to Sebesta? a. Increased capacity to express ideas. b. Improved background for choosing appropriate languages. c. Increased ability to design new languages. d. Increased ability to learn new languages. 2. (p. 5-6.) What programming language has dominated scientific computing over the past 50 years? a. FORTRAN b. ALGOL c. SNOBOL d. PL/I 3. (p. 6.) What programming language has dominated artificial intelligence...

  • Python Activity 05 Boolean Expressions - POGIL (5) - Word Search m Layout References Mailings Review...

    Python Activity 05 Boolean Expressions - POGIL (5) - Word Search m Layout References Mailings Review View Help Critical Thinking Questions Programming Structures Sequence Structure Decision or Branching Structure Looping Structure FALSE Which structure best describes the types of Python programs you have written so far? _sequence structure Which structure allows the programmer to create code that decides what code is executed? FYI: Conditional operators, also known as relational operators, are used to compare the relationship between two operands. Expressions...

  • (b) Evaluate the following C++ expressions and show in the boxes under the operators the of...

    (b) Evaluate the following C++ expressions and show in the boxes under the operators the of evaluation of the corresponding operations. [2.5 points each): Expression Value 7 / 2 != 6 / 2 && 9 <3 * 7 2 + 3 + 4 / 2 6 + 8% 3 abs (4 7) + 3 / 2 * pow (5.0,2)

  • 1. (9 points, 3 points each) Using the Boolean identities, simplify the following expressions: a. (x7)Zi)(2+...

    1. (9 points, 3 points each) Using the Boolean identities, simplify the following expressions: a. (x7)Zi)(2+ y) b. 7(xyz) + y(ż + (7 +z)) C. (xz + ✓x) + y(x+y)(7+ y)

  • 1. Given: p: x > 4; q: x <= -2. Translate the following into Boolean Expressions...

    1. Given: p: x > 4; q: x <= -2. Translate the following into Boolean Expressions and simplify if possible. a. q b. ^p c. p^q d. *p v *q e, p>q For the compound expressions: c, d, and e, identify the ones that portray an impossible situation (i.e., simplify to Ø) and explain why.

  • Using the production function Q = ( and output levels of Q=2, Q=4, Q=6 A). Suppose...

    Using the production function Q = ( and output levels of Q=2, Q=4, Q=6 A). Suppose the price of L and K is $3/hr. On a graph show isocost lines corresponding to total costs of $12, $24, and $36. Using isoquants and isocost lines, locate three points on the expansion path and draw the expansion path. Show your calculations. B). Using the three points on the expansion path, calculate the firm's long run total and average costs at each of...

  • Stacks are used by compilers to help in the process of evaluating expressions and generating machine...

    Stacks are used by compilers to help in the process of evaluating expressions and generating machine language code.In this exercise, we investigate how compilers evaluate arithmetic expressions consisting only of constants, operators and parentheses. Humans generally write expressions like 3 + 4and 7 / 9in which the operator (+ or / here) is written between its operands—this is called infix notation. Computers “prefer” postfix notation in which the operator is written to the right of its two operands. The preceding...

  • C++ 10:19 AM Tue Oct 9 csive csicuny edu le. Original 3_1 Boolean and A&&B&&c and...

    C++ 10:19 AM Tue Oct 9 csive csicuny edu le. Original 3_1 Boolean and A&&B&&c and AllBIIC in a table with 3 columns Hand in HW #4 36 pts Read study SECs 3.1-3.3 1. Evaluate the following conditional expressions (T or F). 4 pts 2. FLOWCHART THE FOLLOWING (condensed) CODE in et int main) 8 PTS ( int number; cout <"Enter an integer:"; cin >>number if ( number>0) cout <You entered a positive integer:"< number < endl; else if (number...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT