C Language

May 26, 2023

How to use ternary operator in c language

program to use ternary operator in c language


#include<stdio.h>
int main()
{
    int a,b,max;
    printf("Enter a values for a and b : ");
    scanf("%d%d",&a,&b);
    max = a>b ? a : b;
    printf("larger of %d and %d is %d\n",a,b,max);
    return 0;
}

output


Enter a values for a and b : 12
4
larger of 12 and 4 is 12

by : Ajaj Khan

Quick Summary:

इस program मैं ternary operator सहायता से large नंबर निकल रहा है