Hey all, this is a pretty basic program that will take a use submitted array and call functions to find the max,min and then a function to reverse the array. I have the first two functions written and working but I am having trouble with the reverse array function. The reverse function has to use pointers or else I won't get credit. Here is what I have so far, it is no working at the moment.
Guidelines "Implement a separate function to reverse the order of the array using call by reference. The input of this function should be two pointers (pointing to original array and reverse array). This reversed array should be printed in the main function"
Thanks for any and all help!!
-Ryan
#include <stdio.h> // includes the library for the c compiler/program
#include <math.h>
int findmax(int a[]);
int findmin(int a[]);
void swap(int* a[] , int* b[]);
main() //main function of the program
{ //
int basicarray[6];
int reversearray[6];
int i;
int choice;
int max;
int min;
for(i=0; i < 6; i++) {
printf("Please eneter element %d",i);
printf(" of the array\n");
scanf("%d", &basicarray[i]);
}
printf("The array entered is %d %d %d %d %d %d\n\n" , basicarray[0] , basicarray[1] ,
basicarray[2] , basicarray[3] , basicarray[4] , basicarray[5]);
while(1)
{
printf("Please select from the menu below:\n\n");
printf("1. Find Maximum Integer in Array.\n");
printf("2. Find Minimum Integer in Array.\n");
printf("3. Reverse Order of the Array.\n");
printf("4. Exit.\n");
scanf("%d" , &choice);
switch (choice) {
case 1:
max = findmax(basicarray);
printf("Your option is: %d\n" , choice);
printf("The Maximum Integer is %d\n" , max );
break;
case 2:
min = findmin(basicarray);
printf("Your option is: %d\n" , choice);
printf("The Minium Integer is %d\n" , min );
break;
case 3:
for(i=0; i < 6; i++) {
reversearray[i] = swap(&basicarray , &reversearray);
printf("%d", reversearray[i]);
}
break;
case 4:
return 0;
default:
printf("Choice doesn't exsist\n");
break;
}
system("pause"); /*pause to keep information on the screen*/
}
}
int findmax(int a[])
{
int max = a[0];
int i;
for (i=0; i < 6; i++)
{
if(a[i] > max)
{
max = a[i];
}
}
return (max);
}
int findmin(int a[])
{
int min = a[0];
int i;
for (i=0; i < 6; i++)
{
if(a[i] < min)
{
min = a[i];
}
}
return (min);
}
void swap(int* a[] , int* b[])
{
int i = 0;
for (i=0; i<6; i++) {
b[i] =
}
}