Create a program to demonstrate the use of the Conditional Operator in java

 Create a program to demonstrate the use of the Conditional Operator in java

public class TernaryOperator
{
    public static void main(String args[]){
    int a=3;
    int b=10;
    int c;
    c=a>b?(a-b):(b-a);
    System.out.println(c);
    }
}

Output
7

Comments

Popular posts from this blog

How to make simple bill maker by using python tkinter

Make a GST Calculator using HTML and JavaScript

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java