Sunday, March 6, 2016

URI-1001 Solution in C language,java language, C++ languge(Extremely Basic)

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.
Input SamplesOutput Samples
10
9
X = 19
-10
4
X = -6
15
-7
X = 8

Solution in C language:

#include<stdio.h>

int main()
{
   int A, B, X;
   scanf("%d %d",&A,&B); //take input for A and B
   X = A + B;                //Basic summation X = A + B
   printf("X = %d\n", X); //Hardly advised to give \n at last
   return 0;
}


Solution in Java language:


import java.util.Scanner;
public class Main {
 public static void main(String[] args) {

      int A, B, X;
      Scanner sc = new Scanner(System.in);
      A = sc.nextInt();                     //take input for A
      B = sc.nextInt();                    //take input for  B
      X = A + B;                           //Basic summation X = A + B
      System.out.print("X = "+X+"\n");    //Hardly advised to give \n at last

   }

}


OR


import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        InputStreamReader ir = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(ir);

        int A, B, X;

        A = Integer.parseInt(in.readLine());                               //take input for A
        B = Integer.parseInt(in.readLine());                              //take input for  B

        X = A + B;                                                                 //Basic summation X = A + B

        System.out.printf("X = %d\n", X);                              //Print X

    }

}


Solution in C++ language:

#include <iostream>
using namespace std;
int main() {
int A, B, X;
cin >> A >> B; //take input for A and B
X = A + B; //Basic summation X = A + B
cout << "X = " << X << endl;//Print X in given format and endl is endline or it works linke "\n" in c and java
return 0;
}



Solution in PYTHON language:

a = input()

b = input()

X = a + b

print "X = %i" % X


This is the complete solution of URI - 1001 no problem.Since if you face any problem to run it or any other news for any compilation error, presentation error, You can knock me in email- manirujjamanakash@gmail.com

Or You can follow this link and listen it first so attentively to write your first code efficiently.
https://www.urionlinejudge.com.br/judge/en/help


See a video of URI Online Judge Solution 1001 - In C programming - See the 5 minutes video

3 comments:
Write comments

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.