Thursday, June 4, 2020

Write a program in java to input two numbers and find the Smaller Number using conditional operator.

8)  Write a program in java to input two numbers and find the Smaller Number using conditional operator.

import java.util.*;
public class Smaller_using_conditional_operator
{
    public static void main(String args[ ])
    {
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter two numbers");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = (a<b)?a:b;
        System.out.println("Smaller num = "+c);
    }
}

No comments:

Post a Comment

if you have any doubts, Please let me know.
Your Truly
Shashank Porwal

 jhvghvgk ;nkjn ,nkjhj