Sum – Format Print

The program must print the sum of two numbers as per the format given in the Example Input/Output Section.

Example Input/Output 1:
Input:
5 20

Output:
5+20=25

Example Input/Output 2:
Input:
10 200

Output:
10+200=210

Python

X, Y = map(int, input().split())
print(X,'+',Y,'=',X+Y,sep="")

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 + "=" + (num1 + num2));
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int num1, num2;
    scanf("%d%d", &num1, &num2);
    printf("%d+%d=%d", num1, num2, num1 + 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.