Home

A program to explain conditional operator

C Programming Language 007

The following code shows how to write a program to explain conditional operator

Program

#include <stdio.h>

void main()
{

    int a, b, c, d, e;
    printf("Enter the values of a, b: ");
    scanf("%d %d", &a, &b);
    e = (a > b) ? a : b;
    printf("Max = %d", e);

    printf("\n");
}

Result

Enter the values of a, b: 3 5
Max = 5


Last Updated on

Next Post: GraphProtocol: TS2322 null assignment in Subgraph →

Comments