Program to find largest of three numbers | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Program to find largest of three numbers

using If and else

11th Aug 2016, 12:53 PM
chetan wagadare
chetan wagadare - avatar
5 Answers
+ 5
a,b,c=1,2,3 if a>b and a>c: print("A is the Greatest",a) elif b>a and b>c: print("B is the Greatest",b) else: print("C is the Greatest",c)
11th Aug 2016, 1:07 PM
Marco Romanin
Marco Romanin - avatar
+ 5
You can also use the max() function print(max(1,2,3))
11th Aug 2016, 5:49 PM
Elias Grube
Elias Grube - avatar
+ 1
elias's method is the best way to go for that buuuuut if you are required for a class or something to use else and if statements do caco's method
11th Aug 2016, 5:57 PM
Eric Reed
Eric Reed - avatar
0
here is the code.....excellent input <- readLines('stdin') x <- as.integer(input[1]) y <- as.integer(input[2]) z <- as.integer(input[3]) res<-max(x,y,z) print(res)
4th Feb 2022, 8:01 AM
SOI KIPROTICH
- 1
a,b,c=123 if(a>b) print("a is greater ") else if(b>c) print(" b is greater") else print("c is greater")
12th Aug 2016, 8:21 PM
manvi
manvi - avatar