Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the four-step program development of methods development method, write as

ID: 3863010 • Letter: U

Question

Using the four-step program development of methods development method, write as c function with the temple int findMax(int x, int y) to find the maximum of two numbers x and y. Test this function by completing the following code and running it under CodeWarrior. Use "create New Project" to enter CodeWarrior and "Full Chip Simulation" mode. Include all code and debug window screen dumps. #include /* common defines and macros */#include "derivative.h"/* derivative-specific definitions */int findMax(int, int);/* function prototype */int max; void main(void) {/* Insert your declarations here */int arr[6] - {-5, 110, -10, 0, 20, -110);/* find the max of this array of numbers *//* Insert your program statements here to find the max using the function int finMax (int x, int y) */for (;;);} int finMax (int X, int y) {/* Insert your function code here*/}

Explanation / Answer

void main(void)
{
int i,a,b,max1;
int arr[6]={-5,110,-10,0,20,-110};
for(i=0;i<6;i++)
{
a=arr[i];
b=arr[i+1];
findMax(a,b);
}
max1=max;}
int findMax(int x,int y)
{
int max;
if(x>y)
max=x;
else
max=y;
return max;
}

in this program loop runs from 0-5

when i=0;

a=-5;

b=110 now this a and b are passed as paramters to findMax and meximum of these two are found and returned and stored in max1 and this is done untill the loop terminates and at the end of the loop the maximum value from the array is stored in max1 and in this way maximum element is found from the array .