May 26, 2023
program to use ternary operator in c language
#include<stdio.h>
int main()
{
int y,z,max;
printf("Enter values for y and z : ");
scanf("%d%d",&y,&z);
max = z>y ? y : z;
printf("larger of %d and %d is %d\n",y,z,max);
return 0;
}
output
Enter a values for y and z : 12
4
larger of 12 and 4 is 12
Steps Description
- Declare integer three variable
y , z
andmax
printf
inbuild function to display value of variabley and z
with respective decimal placeholder %d- Evaluation of variable
y
andz
to determine greater thanz
- Assign
max
variable with greater than variabley
printf
inbuild function to display larger value of variabley
by : Ajaj Khan
Quick Summary:
इस program मैं ternary operator सहायता से large नंबर निकल रहा है