The World of Numbers – HackerRank Solution

In this post, we will solve The World of Numbers HackerRank Solution. This problem (The World of Numbers) is a part of Linux Shell series.

Task

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 <= X, Y <= 100
  • Y != 0

Output Format

Four lines containing the sum (X + Y), difference (XY), 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)

Solution – The World of Numbers – HackerRank Solution

#!/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 CodingBroz. This tutorial is only for Educational and Learning purpose.

Leave a Comment

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