My school assigment on c includes writing a program that lets u input as many numbers as u want and when u press "0" it stops and then it counts the average of them and also tells u which was the smallest number. Other stuff i can do, but i cant figure out how to print the smallest number that was given. at the moment as u can see in the code, what is supposed to be the smallest number is the first index of the array. please help, im due tommorrow, thank u for ur time.
Code:
#include <stdio.h>
#include <conio.h>
#define SIZE 127
int main()
{
int lkm=0;
int i=1;
int array[127]={0};
int total=0;
do
{
printf("give number %d.", i);
scanf("%d", &array[i]);
lkm++;
i++;
}while(array[i-1]>0);
lkm--;
for(i=1; i<=lkm; i++)
{
total+=array[i];
}
printf("numbers average is %d and the smallest number was %d", total/lkm, array[1]);
getch();
}