2

Calculate square of a number

Difficulty: EASY
Contributed By
Avg. time to solve
15 min
Success Rate
85%

Problem Statement

Given an integer ‘N’, you are supposed to return the square of the given integer without using multiplication (*), division (/) or power function (pow()).

Input format:
The first line contains a single integer ‘T’ denoting the number of test cases.

Each test case contains a single line with a single integer ‘N’ denoting the given number.
Output format:
For each test case, print the square of the given number in a separate line.
Note:
You do not need to print anything; it has already been taken care of.
Constraints:
1 <= T <= 50
-10000 <= N <= 10000

Time Limit: 1 sec.
Sample Input 1:
2
3
-4
Sample Output 1:
9
16
Explanation to Sample Input 1:
In the first test case, the square of 3 is 9.

In the second test case, the square of -4 is 16. 
Sample Input 2:
2
-13
1
Sample Output 2:
169
1
Reset Code
Full screen
copy-code
Console