In this tutorial learn how you can find the larger number between three numbers using a conditional operator. We are using a test case “<test case>? True value: ((<test case>)?True value:false value)”.

This is the shortcut form of the if statement. First, write a statement and use “?” as a separator then the first one is a true case and else or false case which is separated by “:”.

C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.

Write a Program to Find Larger Number Between Three Numbers using Conditional Operator

Here is the code to find the larger number between three numbers using a conditional operator in C programming.

`#include <stdio.h> //WAP to find the larger number between three numbers using conditional operator.int main(){    int a,b,c;    printf("Please enter three numbers:n");   scanf("%d%d%d",&a,&b,&c);   (a>b && a>c)?printf("%d is larger.",a):((b>a && b>c)?printf("%d is larger.",b):printf("%d is larger.",c));    return 0;}`

Conclusion

This is how you can find the larger number between three numbers using conditional operator in c programming. Comment below if you like our tutorial.

Categorized in: