Create array.c

Implement the following five functions. Each takes an array and its size (n) as two of its arguments and computes a specific property of the array.

int max (int array[], int n); - returns the largest value in the array, or 0 if the array has size zero.
int countValue (int array[], int n, int value); - returns the number of times the specified value occurs in the array.
void absolute (int array[], int n); - sets each element in the array to its absolute value
int isSorted (int array[], int n); - returns 1 if the array is sorted in ascending order; 0 otherwise. In the case that the array has size zero, return 1.
int isPermutation (int array[], int n); - returns 1 if the array is a permutation of the integers 1 to n (i.e., it contains each of the integers from 1 to n exactly once) or if the array has size zero; 0 otherwise.
A sample program testing the functions, along with its output, is given below.

Your test program and your solution should be placed in separate files. Submit only the file array.c containing your solution functions.

Sample Test Program

#include <stdio.h>

int max (int array[], int n);
int countValue (int array[], int n, int value);
void absolute (int array[], int n);
int isSorted (int array[], int n);
int isPermutation (int array[], int n);

int main (void)
{
  int i;
  int a[5] = {5,3,2,4,1};
  int b[5] = {-1, 0, 0, 0, 1};
  int c[5] = {-10, 9, -8 , 7, -6};

  printf("max(a, 5) = %d\n", max(a, 5));
  printf("countValue (a, 5, 1) = %d\n", countValue (a, 5, 1));
  printf("countValue (a, 5, 0) = %d\n", countValue (a, 5, 0));
  printf("isSorted (a, 5) = %d\n", isSorted (a, 5));
  printf("isPermutation (a, 5) = %d\n", isPermutation (a, 5));

  printf("max(b, 5) = %d\n", max(b, 5));
  printf("countValue (b, 5, 1) = %d\n", countValue (b, 5, 1));
  printf("countValue (b, 5, 0) = %d\n", countValue (b, 5, 0));
  printf("isSorted (b, 5) = %d\n", isSorted (b, 5));
  printf("isPermutation (b, 5) = %d\n", isPermutation (b, 5));

  absolute (c, 5);
  for (i = 0; i < 5; i++)
    printf ("c[%d] = %d\n", i, c[i]);
  return 0;
}
Sample Output

max(a, 5) = 5
countValue (a, 5, 1) = 1
countValue (a, 5, 0) = 0
isSorted (a, 5) = 0
isPermutation (a, 5) = 1
max(b, 5) = 1
countValue (b, 5, 1) = 1
countValue (b, 5, 0) = 3
isSorted (b, 5) = 1
isPermutation (b, 5) = 0
c[0] = 10
c[1] = 9
c[2] = 8
c[3] = 7
c[4] = 6