Question

In: Computer Science

Explain the results of the following expressions (you may want to show each step of evaluation):...

Explain the results of the following expressions (you may want to show each step of evaluation):

• 4 + 5 * 6 + 7 / 8

• 4 + 5 * 6 < 7 / 8

• 4 + 5 > 6 && 7 < 8

• 1 && 0

Solutions

Expert Solution

(1)   4 + 5 * 6 + 7 / 8

Answer-

  Step (i) To solve this question first we have to find the precedence of all operator

  So according to precedence of operator multiplication (*) and divide( /) have a higher precedence then plus ( + ) and ( - ) . so first we have to calculate multiplication and divide.

After solving the multiplication and divide-

  We know 5 * 6 is 30 and 7 / 8 is 0.

  So 4 + 30 + 0

Step (ii) - now we have to calculate + operation so if one or more operator having same precedence then it will solve with the help of associativity. So in our condition associativity of + operator is Left to right so it will solve left to right.

   4 + 30 + 0 (solve Left to Right)

  So 34 is answer.

(2)   4 + 5 * 6 < 7 / 8

    

In this example we have two type of operator Arithmatic and relational operator.

So according to rule Arithmatic operators have greater precedence then Relational operator.

So first we calculate +, * and /.

   So we know * and / having greater precedence so they solve first.

We know 5 * 6 is 30 and 7 / 8 is 0.

4 + 30 < 0

Now calculate + operator

34 < 0 (this condition is false so it return 0)

Now we calculate relational operator and its return 0 and 1 value.

So in our case condition is false.

So 0 is answer.

(3) 4 + 5 > 6 && 7 < 8

Step ( i)   We know Arithmatic operator have greater precedence then Relational and logical And operators.

So first solve + operator-

   9 > 6 && 7<8

Step ( ii ) now we know relational operator having more precedence then logical Operator so-

       We know 9 is greater then 9 and 7 is less then 9 so both return 1.

1 && 1

In && operator if both digit is non zero then it return True. in our case bot digit is non zero .

So 1 (True) is Answer

(4)   1 && 0

      

We know that logical && operator return true (1) if both digit is non zero . in our case first digit is one that is non zero but second digit is 0.

So it return false(0).

So 0 is answer


Related Solutions

What sort of evaluation involves the evaluation of expressions in each part of a compound, conditional...
What sort of evaluation involves the evaluation of expressions in each part of a compound, conditional Boolean expression only as much as necessary to determine whether the expression is false? a. sequence b. sequential c. short-circuit d. smart
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output...
Regular Expressions Assignment Write a regular expression for each of the following. Can you show output please. A blank line (may contain spaces) Postal abbreviation (2 letters) for State followed by a space and then the 5-digit zip code A KU student username (Ex. lpork247) A “valid” email address (also explain how you defined “valid”) A SSN pattern (ddd-dd-dddd)
(Explain each step in depth and show your logic. Show formulas and the reasons for doing...
(Explain each step in depth and show your logic. Show formulas and the reasons for doing what your doing) You are an analyst evaluating Up-and-Coming Airlines Inc., a very hot potential acquisition candidate your company is considering. Up-and-Coming currently has no debt and you estimate that it should be able to generate $1 million a year from its existing assets (after tax cash flow). Furthermore, it has the opportunity to invest one-half of its earnings indefinitely. You estimate that because...
Linux regular expressions: file name: lab3test.txt Create regular expressions that meet the following criteria. You may...
Linux regular expressions: file name: lab3test.txt Create regular expressions that meet the following criteria. You may use grep or egrep to answer these questions. 1.Match any lines that contain a phone number with the format 222-222-2222.
linux Regular expressions file name: lab3test.txt Create regular expressions that meet the following criteria. You may...
linux Regular expressions file name: lab3test.txt Create regular expressions that meet the following criteria. You may use grep or egrep to answer these questions. 1.Display all lines where the employee’s age is greater than 40 years old. Again, don’t think of this as a number, think of it as a series of characters.
The charts show results of studies on four-year colleges in the United States. You want to...
The charts show results of studies on four-year colleges in the United States. You want to portray your college in a positive light for an advertising campaign designed to attract high school students. You decide to use hypothesis tests to show that your college is better than the average in certain aspects. EXERCISES 1. What Would You Test? What claims could you test if you wanted to convince a student to come to your college? Suppose the student you are...
Please show the each calculate step, thank you A company has identified the following budgeted overhead...
Please show the each calculate step, thank you A company has identified the following budgeted overhead costs and budgeted cost drivers for next year: Activity Budgeted Activity cost Cost Driver    Quantity Material Handling $120,000 Number of moves 3,000 Ordering costs 70,000 Number of orders 50,000 Maintenance 200,000 Machine hours 80,000 Power 310,000 Kilowatt hours 310,000 Total Activity Cost $700,000 The following job completed during the year: Job 400                                           Direct Materials $22,000 Direct labor $6,000 Units completed 4,000 Direct labor...
Directions: For each question, you need to show each step of the hypothesis test, state your...
Directions: For each question, you need to show each step of the hypothesis test, state your null and alternate hypothesis, identify if you are conducting a two-tailed or a one-tailed hypothesis test, identify the Zcrit and Zobt, graph the normal curve, label the critical value and the test statistic, shade the rejection region, tell whether we reject or retain the null and make a conclusion statement. You also need to calculate Cohen’s d, the probability of committing a type I...
Directions: For each question, you need to show each step of the hypothesis test, state your...
Directions: For each question, you need to show each step of the hypothesis test, state your null and alternate hypothesis, identify if you are conducting a two-tailed or a one-tailed hypothesis test, identify the Zcrit and Zobt, graph the normal curve, label the critical value and the test statistic, shade the rejection region, tell whether we reject or retain the null and make a conclusion statement. You also need to calculate Cohen’s d, the probability of committing a type I...
Directions: For each question, you need to show each step of the hypothesis test, state your...
Directions: For each question, you need to show each step of the hypothesis test, state your null and alternate hypothesis, identify if you are conducting a two-tailed or a one-tailed hypothesis test, identify the Zcrit and Zobt, graph the normal curve, label the critical value and the test statistic, shade the rejection region, tell whether we reject or retain the null and make a conclusion statement. You also need to calculate Cohen’s d, the probability of committing a type I...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT