Question: Consider the following algorithm to find the average of two input integers: 1. Consider the following algorithm to find the average of two input integers:

Consider the following algorithm to find the average of two input integers:

Consider the following algorithm to find the average of two input integers:

1. Consider the following algorithm to find the average of two input integers: integer a integer b integer sum integer average a= Get next input b= Get next input sum =a+b average = sum /2 Put average to output This algorithm will not always give you the correct answer. For what inputs will the algorithm not return a valid solution, and how would you fix this? 2. Consider the following incomplete algorithm to swap three values: integer array(3) A integer temp A[0]= Get next input A[1]= Get next input A[2]= Get next input //Swapping logic here Fill in the computational logic to swap three values. The swapping behavior you want is the following: - After swapping, A[0] should hold the value of A[2] - After swapping, A[1] should hold the value of A[0] - After swapping, A [2] should hold the value of A [1] 3. Given two input integers a and b, write an algorithm in Coral to calculate the difference of two squares a2b2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!