URI Online Judge Solution 1003 Simple Sum | Solution in C, C++, Java, Python and C#

Algorithm


URI Online Judge | 1003

Simple Sum

Adapted by Neilor Tonin, URI  Brazil

Timelimit: 1

Read two integer values, in this case, the variables A and B. After this, calculate the sum between them and assign it to the variable SOMA. Write the value of this variable.

Input

The input file contains 2 integer numbers.

Output

Print the message "SOMA" with all the capital letters, with a blank space before and after the equal signal followed by the corresponding value to the sum of A and B. Like all the problems, don't forget to print the end of line, otherwise you will receive "Presentation Error"

 
Input Samples Output Samples

30
10

SOMA = 40

-30
10

SOMA = -20

0
0

SOMA = 0

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include <stdio.h>

int main()
{
 int x, y;

 scanf("%d", &x);
 scanf("%d", &y);
 printf("SOMA = %d\n", x + y);

 return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
30
10

Output

x
+
cmd
SOMA = 40

#2 Code Example with Java Programming

Code - Java Programming

import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        int A, B;
        Scanner sc = new Scanner(System.in);
        A = sc.nextInt();
        B = sc.nextInt();
        System.out.print("SOMA = "+(A+B)+"\n");
  }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
-30
10

Output

x
+
cmd
SOMA = -20

#3 Code Example with Python Programming

Code - Python Programming

A = int(input())
B = int(input())

soma = A + B

print("SOMA = %d" %soma)
Copy The Code & Try With Live Editor

Input

x
+
cmd
0
0

Output

x
+
cmd
SOMA = 0

#4 C# Solution of URI 1003 problem

Code - C++ Programming

using System; 

class URI {

    static void Main(string[] args) { 

        int A = int.Parse(Console.ReadLine());

        int B = int.Parse(Console.ReadLine());

        int sum = A+B;

        Console.WriteLine("SOMA = {0}", sum);

    }

}.
Copy The Code & Try With Live Editor

Input

x
+
cmd
-30
10

Output

x
+
cmd
SOMA = -20

Demonstration


This is a simple summation problem. Just take the two inputs and make a summation of them.

  1. Take two input x and y
  2. Make sum = x + y
  3. Print sum