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

Please do this in the C programming language and also make it so I can copy and

ID: 3739968 • Letter: P

Question

Please do this in the C programming language and also make it so I can copy and paste your code

• You need to write the Main procedure to call the other four procedures at appropriate points, and with the appropriate parametersin registersto passto the procedures, so that they do what is described below. You are allowed to do other work in Main to manipulate parameter valuesto passto the procedures before you call them. Main should also write the values returned by Count and Min to output. Reverse will write to the RArray and Add will write its output directly to output withoutreturning itto Main.

• The Count procedure should determine the number of values in the input array, and return this value to Main. Main will then write the value to output. This value should be in the first memory location in the output. Count should be passed exactly two parameters, namely, a pointer to Array, and the address of the Done label.

long Count(long *Array, long *Done);

• The Min procedure should find the minimum value in the input array and return this value to Main. Main will then write the value to output. This value should be in the second memory location in the output. Min should be passed exactly two parameters, namely, a pointer to Array, and the number of values in Array.

long Min(long *Array, long Count);

• The Reverse procedure should:

                  o write the values in the input array to RArray in reverse order, i.e., from the last value in the input array to the first.

                  o Reverse should be passed three parameters:  a pointer to Array, Count, and a pointer to RArray.  

void Reverse(long *Array, long Count, long *RArray);

• The Add procedure should add the first element of Array to the first element of RArray and print the sum to the next location in the output.  Add should be passed four parameters, a pointer to Array, Count, a pointer to RArray, and the next valid address in Output.

void Add(long*Array, long Count, long *RArray,  long*Output);

Explanation / Answer

long Count(long *Array, long *Done)
{
long count=0;//assuming Done points to the next element to the end of the array
while(Array!=Done)
{
Array++;
count++;
}
return count;
}
long Min(long *Array, long Count)
{
long min=Array[0];
long i=1;
for(i=1;i<Count;i++)
if(min>Array[i])
min=Array[i];
return min;
}
void Reverse(long *Array, long Count, long *RArray)
{
long i=0;
for(i=0;i<Count;i++)
RArray[Count-i-1]=Array[i];
}
void Add(long*Array, long Count, long *RArray, long*Output)
{
long i=0;
for(i=0;i<Count;i++)
Output[i]=RArray[i]+Array[i];
}