80 : C Program to find biggest among 3 numbers using ternary operator

Check out the complete list of c-programs : C Program List    





Find biggest amoung 3 numbers using ternary operator.








/*
 * 1000+ C programs + tutorials
 *
 * 
 * 80_c_program_to_find_biggest_of_3_numbers_using_ternary_operator.c
 *  
 *  
 *
 *  Created on: Oct 25, 2014
 *  Author: Code2care.org
 */

#include 
//#include 

void main() {

int i,max;
int arr[2];

//clrscr();


for(i=0 ; i <=2 ; i++) {

       printf("\n Enter no.%d : ", i+1);
       scanf("%d",&arr[i]);
}
 
 
 max =  (arr[0] > arr[1]) ? (arr[0] > arr[2] ? arr[0] : arr[2]) : (arr[1] > arr[2] ? arr[1] : arr[2]) ;
  printf("\n Max of %d,%d,%d is :  %d ", arr[0],arr[1],arr[2],max);

//getch();  
   
 }










The best way to learn C programming is to practice more and more of programs . Code2care C Programming tutorials provide 1000+ programs in C that you can study and become an expert in the language. Programs are divided into categories depending upon type and complexity.

BSc. IT, BSc. Computer Science, BSc. IT, MSc. IT, MSc. Computer Science, MCA, BTech IT & BTech Engineers may find these programs very useful.