KEMBAR78
C Ternary Operator Example | PDF
0% found this document useful (0 votes)
29 views1 page

C Ternary Operator Example

This C program uses the ternary operator to find the largest of three user-inputted numbers. It prompts the user to input three integers, stores them in variables a, b, and c, then uses a nested ternary operator expression to assign the largest number to the variable larg. It finally prints out the largest number.

Uploaded by

gddydss6t
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

C Ternary Operator Example

This C program uses the ternary operator to find the largest of three user-inputted numbers. It prompts the user to input three integers, stores them in variables a, b, and c, then uses a nested ternary operator expression to assign the largest number to the variable larg. It finally prints out the largest number.

Uploaded by

gddydss6t
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//C program to find the largest of three numbers using ternary operator

#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c, larg;
printf("Enter first number: ");
scanf("%d", &a);
printf("Enter second number: ");
scanf("%d", &b);
printf("Enter third number: ");
scanf("%d", &c);
larg = (a>b)?((a>c)?a:c):((b>c)?b:c);
printf("Largest number is: %d", larg);
getch();
}

You might also like