Question d’entretien chez Chetu

Program to find out middle number among three variables using only if else in java .

Réponses aux questions d'entretien

Utilisateur anonyme

24 juin 2014

I done that program correct but HR said it is incorrect.

Utilisateur anonyme

1 juil. 2014

share your answer too.

Utilisateur anonyme

18 juil. 2018

there is the simple way to answer tjis.. we can just check the alsphabed in ascii code. and then compare.

Utilisateur anonyme

28 nov. 2018

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in= new Scanner(System.in); int [] arr=new int[3]; for (int i=0;i<3;i++) { arr[i]=in.nextInt(); } int mid=MidCalc(arr); System.out.println(mid); } public static int MidCalc(int [] arr) { if (arr[0]

Utilisateur anonyme

8 janv. 2015

var A =10, B=5, C=15, mid=0, flag=0; if(A>B && B>C) mid = B; else if ( A>C && C>B) mid = C; else if ( B>A && A>C) mid = A; else if ( B>C && C>A) mid = C; else if ( C>A && A>B) mid = A; else if ( C>B && B>AB) mid = B; else print("two or more numbers have same value"); flag=1; if(flag=0) { print("Middle number is "+mid); } please ignore any syntax discrepancy. Kindly see logic only.

1

Utilisateur anonyme

14 avr. 2015

var A =10, B=5, C=15, mid=0, flag=0; if(A>B && B>C || C>B && B>AB) mid = B; else if ( A>C && C>B || B>C && C>A) mid = C; else if ( B>A && A>C || C>A && A>B) mid = A; else print("two or more numbers have same value"); flag=1; if(flag=0) { print("Middle number is "+mid); } There is single problem that you increase the execution time with using unneccessary else if while you can use OR operator also.Your logic is right but the execution of its wrong.

Question entretien chez Chetu : Program to find out middle number among three variables using only if else in java . | Glassdoor