Re: My problem in C
So, I am trying to find the largest and the smallest value within an array. but the program spits out random values after the input is done.
Below is the source code, take a look at it, and please tell me what I am doing wrong.
#include <stdio.h>
int main(void)
{
int i, n;
long list[300], maximum, minimum;
printf("Enter a number between 1 to 300:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the number %d",i+1);
scanf("%d",&list[ i ]);
}
for(i=1;i<n;i++)
{
if(list[0]<list[ i ])
{
maximum=list[0];
}
if(list[1]>list[ i ])
{
minimum=list[1];
}//if closed.
}//loop closed
printf("%d %d",maximum,minimum);
}
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector