C Program To Find The Largest Number in Two Variables

C Program to find the Largest Number

Hey Shouters !! Today we will learn about C Program to Find the Largest Number in Two variables. There are two methods to find the Largest number in two variables.

  1. Using Relational Operator (>)
  2. Using Conditional Operator (?:)

The C Program with Conditional Operator is very important and is asked in many big companies. So, it becomes priority to understand the program.

1. C Program To find the Largest Number – Using Relational Operator

In this program we will use if-else statement to check that which number is the largest number. Suppose we have a =20 and b =30. We will add the condition in the if statement, if that statement is correct we will get the output and if that is wrong then else part will be executed.

So, in the above program the statement in the if part is wrong that 20>30. So, else part will be executed and we will get the output.

C Program To Find the Largest Number- Using Conditional Operator

The approach is very simple and does not need to write lengthy code. In this we will just write one line and our problem will be solved. Suppose we have a= 55 and b =45. We will use Conditional operator, if the statement is correct, the first task will be executed otherwise second one.

We daily add Multiple Choice Questions for placement preparation questions and technical interview preparation on the Instagram page. Check the Instagram account: Shout Coders

Frequently Asked Questions –

❓Is it important to understand the Conditional operator

Yes, it is very important to understand the Conditional operator.

❓ Is this program asked in Placement Interviews

Yes, the second method will be asked but only in product based companies.

Recommended Posts –

  1. Introduction to C language
  2. Structure of C program
  3. C Program to add two numbers
  4. C Program to reverse a number
  5. Difference between C and C ++.

Leave a Reply

Your email address will not be published. Required fields are marked *

Close Bitnami banner