Question

(b) Evaluate the following C++ expressions and show in the boxes under the operators the of evaluation of the corresponding o

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

Ans:

Expression Value
7 / 2 != 6 / 2 && 9 < 3 * 7 0
2 * 3 + 4 / 2 - 6 + 8 % 3 4
abs(4-7) + 3 / 2 * pow(5.0,2) 28

############################################################

Here the Operator Precedence are: * then / then != then < then && resulted to the value 0

(7 / 2 != 6 / 2 && 9 < 3 * 7)

3 * 7 = 21

6 / 2 = 3

7 / 2 = 3

(3 != 3 && 9 < 21) -------------> 3!=3 returns False which is 0 and 9 < 21 returns True which is 1

(0 && 1) = 0

############################################################

(2 * 3 + 4 / 2 - 6 + 8 % 3)

Here the Operator Precedence are: * then / then % then + then - which resulted to the value 4

2 * 3 = 6

4 / 2 = 2

8 % 3 = 2

(6 + 2 - 6 + 2) = 4

############################################################

abs(4-7) + 3 / 2 * pow(5.0,2)

Here the Operator Precedence are: ( ) has the highest presidence, which is abs() and pow() then / then * then + then - which resulted the value 28

(abs(4-7) + ((3 / 2) * pow(5.0,2)))

abs(4 -7) = 3

pow(5.0,2) = 25

(3 / 2) = 1

1 * 25 = 25

3 +25 = 28

Add a comment
Know the answer?
Add Answer to:
(b) Evaluate the following C++ expressions and show in the boxes under the operators the of...
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
  • EVALUATING GENERAL INFIX EXPRESSIONS INTRODUCTION The notation in which we usually write arithmetic expressions is called infix notation;...

    EVALUATING GENERAL INFIX EXPRESSIONS INTRODUCTION The notation in which we usually write arithmetic expressions is called infix notation; in it, operators are written between their operands: X + Y. Such expressions can be ambiguous; do we add or multiply first in the expression 5 + 3 * 2? Parentheses and rules of precedence and association clarify such ambiguities: multiplication and division take precedence over addition and subtraction, and operators associate from left to right. This project implements and exercises a stack-based algorithm that evaluates...

  • 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...

  • #1. Operators and values, expressions Please correct the following code to make it print the given...

    #1. Operators and values, expressions Please correct the following code to make it print the given expressions and their answers well (3pts). public class DataTypes {    public static void main(String[] args) {       System.out.println("5*8/6 = " + 5*8/6);       System.out.println("(2*6)+(4*4)+10 = " + (2*6)+(4*4)+10);       System.out.println("6 / 2 + 7 / 3 = " + 6 / 2 + 7 / 3);       System.out.println("6 * 7 % 4 = " + 6 * 7 % 4 );       System.out.println("22 + 4 * 2 = "...

  • Q#2 (6 points) Assume following precedence levels 1. parentheses 2. unary operators 3. **(exponentiation: if the...

    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)

  • Please answer all questions I. Give an example of 2. List operators for arithmetic expressions in...

    Please answer all questions I. Give an example of 2. List operators for arithmetic expressions in python. 3 Give an eample on expression in python 4. List operators for rational/boolean expression in python. 5. Is there any type conversion in the following expression, and why? 9/3.0

  • 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...

  • 11. Evaluate each of the following expressions: a. 4*3/6-4+ Math.pow(7,2) b. (3+4)*7-3 c. 9*2/4+5%3+3 d. 55...

    11. Evaluate each of the following expressions: a. 4*3/6-4+ Math.pow(7,2) b. (3+4)*7-3 c. 9*2/4+5%3+3 d. 55 55

  • We as humans write math expression in infix notation, e.g. 5 + 2 (the operators are...

    We as humans write math expression in infix notation, e.g. 5 + 2 (the operators are written in-between the operands). In a computer’s language, however, it is preferred to have the operators on the right side of the operands, i.e. 5 2 +. For more complex expressions that include parenthesis and multiple operators, a compiler has to convert the expression into postfix first and then evaluate the resulting postfix. Write a program that takes an “infix” expression as input, uses...

  • Using ADT Stack: Evaluating infix expressions by converting them to postfix expressions Postfix notation: In a...

    Using ADT Stack: Evaluating infix expressions by converting them to postfix expressions Postfix notation: In a postfix expression, a binary operation follows its two opperands. The order of the operands in a infix expression is the same as in the corresponding postfix expression but the order of the operators might change based on the precedence of the operators and the existing of paranthses. Infix Postfix a + b a b + (a + b) * c a b + c...

  • 1. Evaluate the following expressions if p = 8, 9 = 3, and the value of...

    1. Evaluate the following expressions if p = 8, 9 = 3, and the value of the variable found is False. Show your work. . q <= p . not (p == 4-5) . q != p % 5 . found or p > 5 and q == p + 5 2. Are you able to draw the truth tables for AND, OR, and NOT logical expressions? - Translate the following problem descriptions into Python. 3. If score is greater...

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