- Related Questions & Answers
- Java program to find largest of the three numbers using ternary operators
- Java program to find maximum of three numbers
- C# program to find the maximum of three numbers
- Python program to find the maximum of three numbers
- C++ program to find the smallest element among three elements
- Program to find largest of three numbers - JavaScript
- What are the ternary operators in Java?
- Program to find the common ratio of three numbers in C++
- C program to Find the Largest Number Among Three Numbers
- How to Find the Largest Among Three Numbers using Python?
- Java program to find the average of given numbers using arrays
- C++ Program to Find Largest Number Among Three Numbers
- Program to find minimum difference between largest and smallest value in three moves using Python
- Program to find the Largest Number using Ternary Operator in C++
- 8085 program to find smallest number between two numbers

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

The conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide, which value should be assigned to the variable. The operator is written as −

variable x = (expression) ? value if true: value if false

public class SmallestOf3NumsUsingTernary { public static void main(String args[]) { int a, b, c, temp, result; a = 10; b = 20; c = 30; temp = a > b ? a:b; result = c > temp ? c:temp; System.out.println("Smallest number is ::"+result); } }

Smallest number is ::10

Advertisements