Friday, March 25, 2016

URI Online Judge Solution | 1004 Simple Product Using C, C++ and Java language

Read two integer values. After this, calculate the product between them and store the result in a variable named PROD. Print the result like the example below. Do not forget to print the end of line after the result, otherwise you will receive “Presentation Error”.

Input

The input file contains 2 integer numbers.

Output

Print PROD according to the following example, with a blank space before and after the equal signal.
Input SamplesOutput Samples
3
9
PROD = 27
-30
10
PROD = -300
0
9
PROD = 0

Solution in C language:





#include <stdio.h>
int main()
{
    int A, B, PROD;
    scanf("%d%d", &A, &B);
    PROD = A*B;
    printf("PROD = %d\n", PROD);
    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 << "PROD = " << A * B << endl; // printf("PROD = %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("PROD = "+(A * B)+"\n");
  }
}




This is a simple summation problem. Just take two input from user and then print the sum writing the word "PROD = ".
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.

URI Link

1 comment:
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.