Home › Forums › C Programming › Two things in an IF statement › Re: Re: Two things in an IF statement
July 16, 2009 at 3:59 pm
#3592
GWILouisaxwzkla
Participant
could do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <br /> include <stdio.h><br /> #define MAX 5<br /> <br /> int main()<br /> <br /> {<br /> <br /> int i = 1;<br /> int number = 0, highNum = 0;<br /> int highPosition = 0;<br /> <br /> printf("This program will choose the largest number entered.");<br /> printf("nWe are going to enter five numbers.nn");<br /> <br /> for (i = 1; i <= MAX; i++)<br /> {<br /> printf("Enter an integer: ");<br /> scanf("%d", &number);<br /> <br /> if (number > highNum)<br /> {<br /> highNum = number;<br /> highPosition = i;<br /> }<br /> }<br /> <br /> printf("nThe largest number entered was %dn", highNum);<br /> printf("nThe number was in position %dn", highPosition );<br /> return 0;<br /> }<br /> <br /> |