**Largest Number of Two Numbers in C,C++,Java and Python**

The program is written to find the largest number between two given numbers. The two numbers are taken as inputs from the user and then the values are compared and the largest value is printed.

**For example,**

If the two numbers are 5 and 10, then the largest number is 10 which will be displayed as output.

INPUT: Two numbers

OUTPUT: Largest number

PROCESS:

Step 1: [Taking the inputs]

Read a, b [two numbers]

Step 2: [Finding the largest number]

If a>b then

Print “a is largest”

Else

Print “b is largest”

[End of ‘if’]

Step 3: Stop.

__TIME COMPLEXITY:__

if(a>b) ---------------------------------- **O(1)**

printf("%d is largest",a);

else -------------------------------------- **O(1)**

printf("%d is largest",b);

The time complexity of this program is **O(1)** means it requires a constant time to execute this program.

__SPACE COMPLEXITY:__

The space complexity of this program is **O(1)** as it requires a constant number of spaces for any given input.

Related

- largest number between two or three numbers
- Find Largest Number by Menu Driven
- Even and Odd numbers
- Swapping Two Values
- Swapping values without third variable
- Leap Year
- Basic Calculator
- Farenheit to Celsius
- ASCII value
- Average Of Numbers
- Average of Even Numbers
- Average Of Odd Numbers
- Sum of n Numbers
- Sum of n Natural Numbers
- Factorial
- Factorial with Recursion
- Multiplication Table
- Exponential without function
- Number Reverse
- String Reverse
- Fibonacci series
- Fibonacci Series with recursion
- Prime Number
- Prime Numbers between 1 and 100
- Prime Numbers in a given range
- Twin Prime
- Twin Prime Range
- Prime factors of a number
- Prime Factors of range of Numbers
- LCM of N numbers
- GCD of N numbers
- Sum of the digits
- Palindrome Number
- Armstrong Number
- Binary to Decimal
- Binary to Octal
- Binary to HexaDecimal
- Decimal to Binary
- Decimal to Octal
- Decimal to Hexadecimal
- Hexadecimal to Binary
- Hexadecimal to Octal
- Hexadecimal to Decimal
- Octal to Binary
- Octal to Hexadecimal
- Octal to Decimal
- Sorting an Array
- Remove Duplicate Elements from an Array
- Left Rotate of an Array
- Right Rotate by 2 of an Array

Contributed by