Given 3 numbers A, B, and C as input print the middle number.

0

 Given  3 numbers A, B, and C as input print the middle number.

Given  3 numbers A, B, and C as input print the middle number. In Java GeeksCodes


Input :- 

a= 10, b=30, c=20

a= 8, b=12, c=14

a= 100, b=50, c=200

a= 5, b=5, c=5

a= 10, b=10, c=20

a= 16, b=45, c=16

Expected Output :- 

20

12

100

5

10

16


Code :- 

public class MyClass {

    public static void main(String args[]) {

      int x,y,z;

      x=16;

      y=45;

      z=16;

      if(x<y){

          if(z<=x){

              System.out.println(x);

          }else if(y<=z){

              System.out.println(y);

          }else{

              System.out.println(z);

          }

      }else {

            if(z<=y){

              System.out.println(y);

          }else if(z>=x){

              System.out.println(x);

          }else{

              System.out.println(z);

          }

      }


    }

}

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates