Dear sir, Please add more programs in this playlist. Like pyramid problem. These days most of the interviewers asked program from Array and String. Please add more commonly asked interview programs
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner obj=new Scanner(System.in); System.out.println("Enter you number1 : "); int a=obj.nextInt(); System.out.println("Enter you number2 : "); int b=obj.nextInt(); System.out.println("Enter you number3 : "); int c=obj.nextInt(); if(a>b) System.out.println("Largest number:"+a); else if (b>c) System.out.println("Largest number:"+b); else System.out.println("Largest number:"+c); } } This one also working.. is it correct..?
import java.util.Scanner; public class LargestOf3Numbers { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter first number:"); int a = sc.nextInt(); System.out.println("Enter second number:"); int b = sc.nextInt(); System.out.println("Enter third number:"); int c = sc.nextInt(); if((a>b)&(a>c)){ System.out.println(a+" is the Largest number"); } else if((b>a)&(b>c)){ System.out.println(b+" is the Largest number"); } else { System.out.println(c+" is the Largest number"); } } }
I am following your tutorial for testing because i am fresher and excellent explanations and very useful for real time interview than you sir
Or you can use Math.max(a, math.max(b, c))
Dear sir, Please add more programs in this playlist. Like pyramid problem. These days most of the interviewers asked program from Array and String. Please add more commonly asked interview programs
Yes. Sure
@@sdetpavanyes pls sir
Sir, Your teaching skill is Awesome.
Thanks
int temp = Math.max(num1,num2);
int max = Math.max(temp,num3);
Excellent one.Incase a=10,b=10,c=3 which is greater
a=b so both are greater
Output will be 10. It's not returning the larger variable . It returns the value of larger variable.
Your lectures are so good, I get so focused on the content that I forget to like and comment on the videos. RESPECT🙏🙏
Glad you like them!
Hello People in interviews asking solution from hackerrank,codebase etc.. please do video on datastructure and algorithim based programs
we can also solve this problem by nested if else statement . BTW nice explanation
Excellent sir.
Amazing 🎉
Thanks
int max=a>b?(a>c?a:c):(b>c?b:c);
System.out.println(max);
I think its also valid
You are vera level sirrrrrr 🔥🔥🔥
thanks
Thank you again🙏 Sir kyunki mujhe code likhna nhi ata.
thanks
Welcome
Awesome sir
Thanks
Nice sir...
Thanks
WoW great!
Thanks
In the first method if I give my inputs as a=50,b=50,c=50 it doesn't give proper output.
hi sir am following all your tutorials excellent sir can you make a clear list the same way which u have prepared in this way on selenium also tq sir
Am stuck with the "else" part of the code saying syntax error
import java.util.Scanner;
public class Main {
public static void main(String args[])
{
Scanner obj=new Scanner(System.in);
System.out.println("Enter you number1 : ");
int a=obj.nextInt();
System.out.println("Enter you number2 : ");
int b=obj.nextInt();
System.out.println("Enter you number3 : ");
int c=obj.nextInt();
if(a>b)
System.out.println("Largest number:"+a);
else if (b>c)
System.out.println("Largest number:"+b);
else
System.out.println("Largest number:"+c);
}
}
This one also working.. is it correct..?
I have one doubt in this , we a=10,b=5,c=20 . In your if statement à>b , so it prints a is greatest . It did not check for c
No its wrong you have to compare all two values with the third val i mean a should be cmpared with b & C both
u have to compare 2 values using and & operator
import java.util.Scanner;
public class LargestOf3Numbers {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter first number:");
int a = sc.nextInt();
System.out.println("Enter second number:");
int b = sc.nextInt();
System.out.println("Enter third number:");
int c = sc.nextInt();
if((a>b)&(a>c)){
System.out.println(a+" is the Largest number");
}
else if((b>a)&(b>c)){
System.out.println(b+" is the Largest number");
}
else {
System.out.println(c+" is the Largest number");
}
}
}