- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to find smallest of the three numbers using ternary operators
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
Example
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); } }
Output
Smallest number is ::10
- Related Articles
- Java program to find largest of the three numbers using ternary operators
- Java program to find maximum of three numbers
- What are the ternary operators in Java?
- Java Program to Find the Largest Among Three Numbers
- C++ program to find the smallest element among three elements
- Python program to find the maximum of three numbers
- C# program to find the maximum of three numbers
- Program to find largest of three numbers - JavaScript
- Program to find the Largest Number using Ternary Operator in C++
- Java program to find the average of given numbers using arrays
- Java Program to Find the Sum of Natural Numbers using Recursion
- Java Program to Find the Product of Two Numbers Using Recursion
- Ternary Operators in C/C++
- Java Program to Find Sum of N Numbers Using Recursion
- Program to find minimum difference between largest and smallest value in three moves using Python

Advertisements