URI 1001 : Solve in C, C++, Java and Python




Question: URI 1001


Read 2 integer values and store them in variables, named A and B and make the sum of these two variables, assigning its result to the variable X. Print X as shown below. Don't present any message beyond what is being specified and don't forget to print the end of line after the result, otherwise you will receive “Presentation Error”.

Input

The input file contain 2 integer values.

Output

Print the variable X according to the following example, with a blank space before and after the equal signal. 'X' is uppercase and you have to print a blank space before and after the '=' signal.
Input SamplesOutput Samples
10
9
X = 19
-10
4
X = -6
15
-7
X = 8


Solution


Solution In C Language:


#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d",&a,&b);
    printf("X = %d\n", a+b);
    return 0;
}

Solution In C++ :

#include<iostream>
using namespace std;

int main(){
    int A, B;
    cin >> A >> B ;                        //scanf("%d%d", &A,&B);
    cout << "X = " << A+ B << endl;    // printf("SOMA = %d\n", A+B);
    return 0;
}

Solution In Java:


import java.util.Scanner;
public class URI_1003 {
    public static void main(String[] args){
        int A, B;
        Scanner sc = new Scanner(System.in);
      A = sc.nextInt();
        B = sc.nextInt();
        System.out.print("X = "+(A+B)+"\n");
  }
}


Solution in Python:


Previous Post
First
Related Posts