• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Largest numbers

 
rk chowdary
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
int A,B,C 3 variables is there.when we are giving input values of these three variables..How to find the largest number.
pls send some logic of the code.
 
Sri Ram
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Check This.

math.max(math.max(a,b),c)


[ January 16, 2006: Message edited by: Sri Ram ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sri meant using the Math class (notice the capital letter )

You could simply use the '<' or '>' operators instead.
 
Adam Price
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rk chowdary:
int A,B,C 3 variables is there.when we are giving input values of these three variables..How to find the largest number.
pls send some logic of the code.


Here's a crude way to do it:
Logic:
int a = arg[0]
int b = arg[1]
int c = arg[2]

int largest = a
if (b> largest) {largest =b}
if (c > largest) {largest = c}
print largest.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic