The World of Numbers HackerRank Solution

Hello Programmers, In this post, you will know how to solve the The World of Numbers HackerRank Solution. This problem is a part of the HackerRank Linux Shell Series.

The World of Numbers HackerRank Solution
The World of Numbers HackerRank Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

Problem

Given two integers, X and Y, find their sum, difference, product, and quotient.

Input Format

Two lines containing one integer each (X and Y, respectively).

Constraints

  • -100 <= XY <= 100
  • Y != 0

Output Format

Four lines containing the sum (X + Y), difference (X – Y), product (X x Y), and quotient (X / Y), respectively.
(While computing the quotient, print only the integer part.)

Sample Input

5
2

Sample Output

7
3
10
2

Explanation

  • 5 + 2 = 7
  • 5 – 2 = 3
  • 5 * 2 = 10
  • 5 / 2 = 2 (Integer part)

The World of Numbers HackerRank Solutions

#!/bin/bash
read X
read Y
echo $((X+Y))
echo $((X-Y))
echo $((X*Y))
echo $((X/Y))

Note: This problem (The World of Numbers) is generated by HackerRank but the Solution is Provided by  BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: Comparing Numbers HackerRank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *