#include <stdio.h>#define SIZE 10#include <stdlib.h>#include <time.h>//define some keywords for the printArray function#define NOSORT 0#define ASCSORT 1#define DESCSORT 2int seed(){ //this is to get some better values out of the randomize funktion int i, stime; long ltime; /* get the current calendar time */ ltime = time(NULL); stime = (unsigned) ltime/2; srand(stime);}int menu(){ int choice =0; while(choice <1 || choice > 6) { printf("\n\nMenu for lab4\n\n 1. Enter numbers into array\n 2. Print the array\n 3. See whats the smallest number in the array\n 4. See whats the biggest number in the array\n 5. Sort it ascendingly\n 6. Sort it descendingly\n\n 0.Exit the program\nYour choice:"); scanf("%d",&choice); return choice; }}int enterArray(int *ptr){ int choice = 0; while(choice >3 || choice <1) { printf("\n\n Lets add some numbers to the array:\n 1. Manually\n 2. Let the computer randomize some numbers for us\nYour choice: "); scanf("%d", &choice); } int i; switch(choice) { case 1: { for(i=0; i<SIZE; i++) { printf("Enter number into array[%d]: ",i); scanf("%d",(ptr + i)); } break; } case 2: { seed(); // seed the random function for(i = 0; i<SIZE; i++) { *(ptr + i) = rand() % 100; } break; } } return 0;}int printArray(int *ptr, int sort){ int i; int temp; switch(sort) { case 1: { for(i=0; i<SIZE-1; i++) { if(*(ptr + i) > *(ptr +i +1)) { temp = *(ptr + i + 1); *(ptr + i +1) = *(ptr + i); *(ptr + i) = temp; i = -1; } } break; } case 2: { for(i=0; i<SIZE-1; i++) { if(*(ptr + i) < *(ptr +i +1)) { temp = *(ptr + i +1); *(ptr + i + 1) = *(ptr + i ); *(ptr + i) = temp; i = -1; } } break; } } printf("\n\nThe array looks like this: "); for(i=0; i<SIZE; i++) { printf("%d ",*(ptr + i)); } return 0;}int biggSmall(int *ptr, int big){ int i; int temp = *(ptr); if(big) { for(i=0; i<SIZE; i++) { if(temp < *(ptr + i)) temp = *(ptr + i); } printf("\nThe biggest value in the array is: %d",temp); } else { for(i=0; i<SIZE; i++) { if(temp > *(ptr + i)) temp = *(ptr + i); } printf("\n The smallest value in the array is %d",temp); } return 0;}int main(){ int choice; int theArray[SIZE] = {}; int *ptr; ptr = theArray; while(choice = menu()) { switch(choice) { case 1: { enterArray(ptr); break; } case 2: { printArray(ptr,NOSORT); break; } case 3: { biggSmall(ptr,0); // check if its the smallest number break; } case 4: { biggSmall(ptr,1); //check if its the biggest number break; } case 5: { // printf("going to print the array "); printArray(ptr,ASCSORT); break; } case 6: { printArray(ptr,DESCSORT); break; } } }}