Largest of Two Numbers

The program must accept two numbers and print the largest number.

Example Input/Output 1:
Input:
12 25

Output:
25

Example Input/Output 2:
Input:
9 5

Output:
9

Python

X, Y = map(int, input().split())
print(X-Y) 

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt();
int num2 = sc.nextInt();
System.out.print(num1 - num2);
}
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int num1, num2;
    scanf("%d%d", &num1, &num2);
    if(num1 > num2)
    {
        printf("%d", num1);
    }
    else
    {
        printf("%d", num2);
    }
}

C++

#include <iostream>
using namespace std;
int main()
{
    int num1, num2;
    cin >> num1 >> num2;
    cout << (num1 > num2 ? num1 : num2);
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.