The program is written here to design a menu-driven program to find the **largest number between two or three numbers**. According to the choice of the user, the inputs are taken, and then the largest number is found and printed.

**For example,** if the **two numbers are 5 and 8**, then the **largest number** is **8**.

If the** ****three numbers are** **5**, **2**, and **4** then the **largest number** is **5**.

```
INPUT: Two or Three numbers according to the user choice.
OUTPUT: The largest number among two or three numbers.
PROCESS:
Step 1: [function to find the largest between two numbers]
Read a, b [two numbers]
If a>b then
Print “a is largest”
Else
Print “b is largest”
[End of ‘if’]
Step 2: [Function to find the largest between three numbers]
Read a, b, c [three numbers]
If a>b and a>c then
Print “a is largest"
else if b>a and b>c then
Print “b is largest"
else
Print “c is largest"
[End of ‘if’]
Step 3: [Main function]
Print “1. Find the largest between two numbers
2. Find the largest between three numbers
Enter your choice”
Read ch [choice]
If ch=1 then
Call the function to find the largest number between two numbers
Else If ch=2 then
Call the function to find the largest number between three numbers
Else
Print “Wrong Choice”
[End of ‘if’]
[End of ‘main’ function]
Step 4: Stop.
```

__TIME COMPLEXITY:__

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

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

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

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

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

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

else if(b>a&&b>c) ---------------------------- **O(1)**

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

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

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

Here, **O(1)**** **means constant time. Each ‘if’ statement and ‘else’ statement takes a constant time to execute. Therefore, the time complexity of this program is **O(1)**.

__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 of two 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 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