max number program not functioning properly
Code:
#include <stdio.h>
void main () {
int num[5];
int index;
printf("\nEnter 5 numbers : \n");
for(index = 0; index < 5; index++ )
{
scanf("%d",&num[index]);
}
int max = num[0];
for (index = 0; index < 5; index++)
{
if(max < num[index]);
{
max = num[index];
}
}
printf("\nThe largest number you entered was : %d\n",max);
}
I made this and compiled it and it seemed to be working sometimes, like i would enter 5 random numbers and i would get the right answer but other times it will just give me the last number i entered. and now all it does is give me the last number i enter ( of the 5). any suggestions?