What is wrong in the following program? Why isn't it returning smallest element as i have tried to implement. Kindly spot the errors.Please tell me the errors regarding the logic and the syntax.
#include<stdio.h>
int ArrayMinimum(int a[], size_t size);
#define SIZE 9
int main()
{
int a[SIZE];
for (int i = 0; i < SIZE; i++)
{
a[i] = 1 + rand() % 99;
printf("%d ", a[i]);
}
printf("\n\nThe smallest number of the array is %d \n", ArrayMinimum(a, SIZE));
}
int ArrayMinimum(int a[], size_t size)
{
if (size == 1)
{
return a[0];
}
for (int i = 0; i <= size ; i++)
{
if (a[i] > a[i + 1])
{
int temp = a[i + 1];
a[i + 1] = a[i];
a[i] = temp;
}
}
int b[] = { 0 };
for (int y = 0; y < size; y++)
{
b[y] = a[y];
}
ArrayMinimum(b, size -1 );
}