In this tutorial, we are going to write a C Program to show the use of the conditional operator in C Programming with practical program code and step-by-step full complete explanation.

C Program to show the use of conditional operator


C Program to show the use of a conditional operator.

#include<stdio.h>
#include<conio.h>

void main()
{
    int a,b;
	
	clrscr();

	printf("Enter value for a and b: ");
	
	scanf("%d%d",&a,&b);

	(a>b)?printf("a is greater than b"):printf("b is greater than a");

	getch();
}


Output

Enter value for a and b: 5
7
b is greater than a