Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

To check largest among two numbers without using if statement

Posted By: Muhammed Athil     Category: C Programming     Views: 11216

Is it possible to check largest among two numbers without using if statement.... Yes... it is possible. See the program how its works

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter two numbers");
scanf("%d%d",&a,&b);
c=a>b?a:b;
printf("The largest number is %d",c);
getch();

}

Out put

Enter two numbers
10
20
The largest number is 20



                                                     plz comment
                                                                Thanks
                           *******
                     

  
Share: 

 
 
 


Muhammed Athil
Muhammed Athil author of To check largest among two numbers without using if statement is from Calicut, India. Muhammed Athil says

Hello Everyone,I am Muhammed Athil from India

 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Muhammed Athil from India Comment on: Apr 06
it is Done by using Conditional operator (?:)
Some example:
average = (n > 0) ? sum / n : 0;
e1 ? e2 : e3;

View All Comments