find biggest number given numbers in c langua

Assembled Intel boxd945gccrl micro atx i...
May 26, 2010 at 23:09:48
Specs: xp
how to find large given 4 nos using (nested if)

See More: find biggest number given numbers in c langua

Report •

#1
June 2, 2010 at 17:56:03
make variables for each number. make each variable = to console input. then do something like (generically) if A>b && a>c && a>d, then write on console a + "is the largest" (and so on. replace a with the variable for next trial, like make it b>a && b>c && b>d, etc)

Report •

#2
June 3, 2010 at 04:24:18
Or alternatively put the numbers into an array and do a bubble sort on the array.

http://mathbits.com/mathbits/compsc...

There is only one If/Then statement nested within a nested For Next loop.

Stuart


Report •

#3
June 3, 2010 at 21:01:35
x = firstnum

if x > secondnum
.x = secondnum
.if x > thirdnum
..x = thirdnum
..if x > fourthnum
else
.if x > thirdnum
..x = thirdnum
..if x > fourthnum
...x > fourthnum
.else
.if x > fourthnum

x is greatest num

or maybe this :)

if {firstnum>secondnum and firstnum>thirdnum and firstnum>fourthnum}
firstnum is greatest
else
. if {secondnum>firstnum and secondnum>thirdnum and secondnum>fourthnum}
secondnum is greatest
.else
..if {thirdnum>firstnum and thirdnum>secondnum and thirdnum>fourthnum}
thirdnum is greatest
..else
fourthnum is greatest

I'm learning.


Report •
Related Solutions


Ask Question