Algorithm
URI Online judge 1001 Problem Link: https://www.urionlinejudge.com.br/judge/en/problems/view/1001
Simple Algorithm -
- Take Two input
- Make sum = input 1 + input 2
- Print Result
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main()
{
int A, B, X;
scanf("%d %d", &A, &B);
X = A + B;
printf("X = %d\n", X);
return 0;
}
Copy The Code &
Try With Live Editor
Input
9
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, X;
Scanner sc = new Scanner(System.in);
A = sc.nextInt(); // input for A
B = sc.nextInt(); // input for B
X = A + B; //Basic summation X = A + B
System.out.print("X = "+X+"\n"); // Advised to give \n at last
}
}
Copy The Code &
Try With Live Editor
Input
4
Output
#3 Run with PHP Programming Language
Code -
PHP Programming
<?php
$input1 = intval(fgets(STDIN));
$input2 = intval(fgets(STDIN));
$summation = $input1 + $input2;
echo "X = $summation\n";
?>
Copy The Code &
Try With Live Editor
Input
Output
Demonstration
Problem Details:
Extremely Basic
Adapted by Neilor Tonin, URI Brazil
Read 2 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. Print endline after the result otherwise you will get “Presentation Error”.
Input
The input file will contain 2 integer numbers.
Output
Print the letter X (uppercase) with a blank space before and after the equal signal followed by the value of X, according to the following example.
Obs.: don't forget the endline after all.
Samples Input | Samples Output |
10 |
X = 19 |
-10 |
X = -6 |
15 |
X = 8 |