Subtract Two Numbers

The program must accept two numbers and subtract them.

Example Input/Output 1:
Input:
100 40

Output:
60

Example Input/Output 2:
Input:
50 200

Output:
-150

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 N1, N2;
    scanf("%d %d", &N1, &N2);
    printf("%d", N1 - N2);
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N1, N2;
    cin >> N1 >> N2;
    cout << N1-N2;
    return 0;
}
Previous Article

Multiply by 2

Next Article

Rearrange Integer Matrix - Alphabets

Write a Comment

Leave a Comment

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