Algorithm
Simple Sum
Adapted by Neilor Tonin, URI Brazil
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 |
SOMA = 40 |
-30 |
SOMA = -20 |
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
10
Output
#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
10
Output
#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
0
Output
#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
10
Output
Demonstration
This is a simple summation problem. Just take the two inputs and make a summation of them.
- Take two input
x
andy
- Make
sum = x + y
- Print
sum