Program to print the larger of two numbers using conditional operator | operators Example Programs in C

Spread the love

Program :

  1. #include<stdio.h>
  2. int main(void)
  3. {
  4.         int a,b,max;
  5.         printf(“Enter values for a and b :”);    
  6.         scanf(“%d%d”,&a,&b);
  7.         max = a>? a : b;              /*ternary operator*/
  8.         printf(“Larger of %d and %d is %dn,a,b,max);
  9.         return 0;
  10. }

Output :

Enter values for a and b : 10 20
Larger of 10 and 20 is 20

Related programs :

  1. program to understand Prefix and postfix Increment.
  2. C program to find quadratic equation roots.
  3. program to understand Floating point Arithmetic’s.
  4. implementation of power function.

Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply