0

Convert to Hexadecimal

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

Problem Statement
Suggest Edit

You are given an integer N. Your task is to convert the number to its equivalent Hexadecimal.

Note - All letters in Hexadecimal (A-F) must be in uppercase.

For example:

If N = 50, then output will be 32.
If N = -50, then output will be FFFFFFCE.

Input format:

The first line of input contains an integer ‘T’ denoting the number of test cases.
Then the T test cases follow.

Each test case contains an integer N.

Output format:

For each test case, return the corresponding Hexadecimal format of the given decimal (integer) number N.
Note :
You are not required to print anything; it has already been taken care of. Just implement the given function.
Constraints :
1 <= T <= 5
-10^4 <= N <= 10^4

Time Limit: 1 sec

Sample Input 1:

3
14
100
-20

Sample Output 1:

E
64
FFFFFFEC

Sample Input 2:

3
45
64
-1

Sample Output 2:

2D
40
FFFFFFFF
Reset Code
Full screen
copy-code
Console