InterviewSolution
| 1. |
Write a program to display the larger number out of the two given unequal numbers |
|
Answer» Answer: Hola Abdul!Here is Your Answer ----------------------------------------------------------------------------------- import java.util.Scanner; class program{ // You Can Write Your Program Name Accordingly public static void main(String [] args){ Scanner sc=new Scanner(System.in); int n1, n2, lar; System.out.println("Enter any two Numbers:"); n1 = sc.nextInt(); n2 = sc.nextInt(); lar = Math.max(n1, n2); System.out.println("Largest No. is: "+lar); } } ----------------------------------------------------------------------------------- Explanation: The Explanation is so SIMPLE. I have Used the Scanner Class to GET the User Data OUTPUT ie Numbers and I Have use a max function from Math Library. I Have Simply Pass the Arguments and we Got the Required Output ie the Largest Number.. ----------------------------------------------------------------------------------- HOPE THIS ANSWER HELPS YOU OUT! MARK AS BRAINLIST!! ----------------------------------------------------------------------------------- |
|