Largest of 3 numbers

Easy
0/40
79 upvotes
Asked in company
BigDataLogin

Problem statement

Write a program that takes three numbers a,b, and c as input and prints the largest number amongst them.

Detailed explanation ( Input/output format, Notes, Images )

Input Format:

The only line of input contains three space-separated integers.

Output Format:

The only line of the output prints the largest integer.
Sample Input 1 :
4 6 1
Sample Output 1 :
6
Explanation of Sample Input 1:
6 is the highest of amongst all.
Sample Input 2 :
-32 -23 -76
Sample Output 2 :
-23
Explanation of Sample Input 2:
-23 is the highest of amongst all.
Sample Input 3 :
-4 0 5
Sample Output 3 :
5
Explanation of Sample Input 2:
5 is the highest of amongst all.
Approaches (1)
Brute-force method

Take input in 3 variables, a, b and c suppose.

Now,

if (a ≥ b  &&  a ≥ c ) print a 

else if ( b≥ a && b ≥ c) print b

else print c .

Time Complexity
Space Complexity
Code Solution
(100% EXP penalty)
Largest of 3 numbers
Full screen
Console