Ternary operator in C programming

#include<stdio.h>
#include<conio.h>
int main()
{
    int x,y,num;
    printf("enter two number:");
    scanf("%d%d",&x,&y);
    num= x>y ? x:y;
    printf("%d is greater",num);
    getch();
    return 0;
}
output
here if x>y is true then num takes x value otherwise num takes value y.


No comments

Powered by Blogger.