C Program to Find Maximum of Two Numbers using Conditional Operator

In this C program, we will find maximum of the two numbers using conditional or ternary operator.

Required Knowledge


C program to find maximum of two numbers using conditional operator

#include <stdio.h>  
  
int main() {  
    int a, b, maximum;  
  
    printf("Enter Two Integers\n");  
    scanf("%d %d", &a, &b);  
  
    if(a == b){
        printf("Both Equal\n");
        return 0;
    }
    
    maximum = (a > b) ? a : b;  
  
    printf("%d is Maximum\n", maximum);  
  
    return 0;  
} 
Output
Enter Two Integers
10 14
14 is Maximum

Related Topics
C program to find maximum of two numbers
C program to find maximum of three numbers
C program to add digits of a number
C Program to generate arithmetic progression(AP) series
C program to make a simple calculator using switch statement
C program to reverse a number using recursion
C program to convert decimal numbers to binary numbers
C program to check armstrong number
C program to print name of days in week using switch statement
List of all C programs