Skip to content

Instantly share code, notes, and snippets.

@PramodDutta
Created October 17, 2024 00:26
Show Gist options
  • Save PramodDutta/f66224d2c6086889a75c97b58e2c7254 to your computer and use it in GitHub Desktop.
Save PramodDutta/f66224d2c6086889a75c97b58e2c7254 to your computer and use it in GitHub Desktop.
Task 2
public class MaxNumber {
public static void main(String[] args) {
int num1 = 10; // Example number 1
int num2 = 20; // Example number 2
// Using ternary operator to find maximum
int max = (num1 > num2) ? num1 : num2;
// Printing the result
System.out.println("The maximum of " + num1 + " and " + num2 + " is: " + max);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment