Hi expert,
I need to write a program, function one assigns the maximum and minimum values in intArray to the variables pointed by min and max respectively. The parameter size is the size of intArray.
Code:
void findMinMax(int intArray[], int size, int* min, int* max)
Function two returns the smallest positive integer (greater than zero) found in intArray.
Code:
int findSmallestPositive(int intArray[], int size)
The array parameter should be traversed only once to maximize the running efficiency of
the function.
This is my script:
Code:
#include <stdio.h>
#include <limits.h>
void findMinMax(int intArray[], int size, int* min, int* max) {
size=2;
if (min<max) {
intArray[0]=min;
intArray[1]=max;
}
else {
intArray[0]=max;
intArray[1]=min;
}
;
}
int findSmallestPositive(int intArray[], int size) {
size=2;
if (intArray[0]<intArray[1])
return intArray[0];
else
return intArray[1];
}
Am my code writing correctly? please told me my error