14) Write a program in java to find Smallest Number in three number using conditional operator.
import java.util.*;public class Smaller_in_three_using_conditional_operator{ public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter three numbers");int a = sc.nextInt();int b = sc.nextInt();int c = sc.nextInt();int d = (a<b) ? (a<c)?a:c : (b<c)?b:c ;System.out.println("Smaller num = "+d);}}
No comments:
Post a Comment
if you have any doubts, Please let me know.
Your Truly
Shashank Porwal