Friday, March 25, 2016

URI online Judge Solution -1003 -Simple Sum by C, C++ and java language

Main link: https://www.urionlinejudge.com.br/judge/en/problems/view/1003
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 variable 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 SamplesOutput Samples
30
10
SOMA = 40
-30
10
SOMA = -20
0
0
SOMA = 0


You can see a simple video on URI 1003 solution in C language in YouTube-




Solution in C language:


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

Solution in C++ language:


#include<iostream>
using namespace std;

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


Solution in java language: 

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("SOMA = "+(A+B)+"\n");
  }
}

This is a simple summation problem. Just take two input from user and then print the sum writing the word "SOMA = ".

Obviously, you have to give a new line at the end of the code. The new line formate in C and java language is "\n". and in  C++ language it can be given by two option like---> "\n" or endl

I think, there will be no problem to clear the above problem. Since if you face any problem to solve the question , you can better comment below.

The main link of the problem is : https://www.urionlinejudge.com.br/judge/en/problems/view/1003




No 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.