C program to find largest of two given numbers is discussed here. Input two integers from the user and find the largest number among them. Given two numbers num1 and num2. The task is to find the largest number among the two.
Algorithm to find the greatest of two numbers
- Ask the user to enter two integer values.
- Read the two integer values in num1 and num2 (integer variables).
- Check if num1 is greater than num2.
- If true, then print ‘num1’ as the greatest number.
- If false, then print ‘num2’ as the greatest number.
Below is the C program to find the largest among the two numbers:
Find the largest of two numbers using the if-else condition:
Please Enter Two different values: 27 6
27 is Largest
Find the largest of two given number using ternary condition:
Please Enter Two different values 6 6
Both numbers are equal