find the max value in an array ?
can anyone tell me whats wrong with this program ?
i've just learned what are arrays so don't know much about it, i want to write a program that prints the max value inside an array.
i wrote this:
int main(void)
{
int temp[2];
int i,max=0;
for (i=0;i<2;i++)
{
printf ("Enter value for Temperature %d:",i);
scanf ("%d",&temp[i]);
}
for (i=0;i<2;i++)
{
max=temp[i];
if (temp[i]>max)
printf ("%d ",temp[i]);
}
getche ();
}
but this is not working :(