The World of Numbers HackerRank Solution

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

The World of Numbers HackerRank Solution

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 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 chase2learn. This tutorial is only for Learning and Educational purpose.

Leave a Comment