I'm assigning values from 0-30 to an array and expecting it to tell me that the smallest element is element no. 0, with the value of 0. But it tells me that the smallest element is element no. 1, with the value of 1.
//header files
#include<stdio.h>
//Initializing constants
int grill[31] = {0};
int i;
int j;
int high;
int low;
int main(void)
{
for(i=0;i<=30;i++)
{
grill[i] = i;
}
for (j=0;j<=30;j++)
{
if (grill[j]>grill[high]) high=j;
if (grill[j]>0 && grill[j]<low) low=j;
if (grill[low]==0) low=j;
}
//utskrift
printf("\n\n The largest element is element nr %d. The value is %d", high,grill[high]);
printf("\n\n The smallest element is element nr %d. The value is %d", low, grill[low]);
return 0;
}