Program to check relation between two numbers in java. || Else-if statement.

import java.util.*;
public class elseif {
    public static void main(String[] args) {
        int a,b;
        Scanner sc =new Scanner(System.in);
        System.out.println("enter value of a=");
        a=sc.nextInt();
        System.out.println("enter value of b=");
        b=sc.nextInt();
        if(a==b){
            System.out.println(" both are same.");
        }
        else if(a>b)
        {
            System.out.println("a is greater.");
        }
        else{
            System.out.println("b is greater.");
        }
    }
    
}
■》 Output->

enter value of a= 3
enter value of b= 1

a is greater.

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.