Find Largest of three double numbers if and Logical Operators

By | March 7, 2020

Find Largest of three double numbers

#include <stdio.h> 
  
int main() 
{ 
     
    int n1, n2, n3, max; 
      
     
    printf("Enter first number=");
	scanf("%d",&n1);
	
	
	printf("Enter second number=");
	scanf("%d",&n2);
	
	printf("Enter third number=");
	scanf("%d",&n3);
	
	max = (n1 > n2) ? (n1 > n3 ? n1 : n3) : (n2 > n3 ? n2 : n3); 
      
     
    printf("Largest number among %d, %d and %d is %d.",n1, n2, n3, max); 
  
    return 0; 
} 

Output

Please Enter three different numbers: 20.50 40.23 90.7
90.70 is the largest number.

Loading

Leave a Reply

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