Home Forums C Programming Two things in an IF statement Re: Re: Two things in an IF statement

#3592
GWILouisaxwzkla
Participant

could do something like this:


include
#define MAX 5

int main()

{

int i = 1;
int number = 0, highNum = 0;
int highPosition = 0;

printf("This program will choose the largest number entered.");
printf("nWe are going to enter five numbers.nn");

for (i = 1; i <= MAX; i++)
{
printf("Enter an integer: ");
scanf("%d", &number);

if (number > highNum)
{
highNum = number;
highPosition = i;
}
}

printf("nThe largest number entered was %dn", highNum);
printf("nThe number was in position %dn", highPosition );
return 0;
}