Blog Moved

This website completely moved to new domain. For latest content, visit www.programmingposts.com

Search This Blog

25 Jul 2012

C program to find the Largest of Three Numbers using Conditional Operator


C program to find the Largest of Three Numbers using Conditional Operator..

PROGRAM:

#include<stdio.h>
int main()
{
  int a,b,c,large;

  printf("\n Enter Three Numbers:");

  scanf("%d %d %d", &a , &b , &c);

  large = (a>b && a>c ? a : b>c?b:c) ;
  /* if a>b and a>c then large=a, else check whether b>c if 
    yes large=b else large=c */
  printf("\n The Largest Number is: %d",large);

  return(0);
}

Sample Output:  ( using GNU GCC Compiler with Code Blocks IDE )

Enter Three Numbers: 5 7 6
The Largest Number is: 7


No comments:

Post a Comment