Algorithm
Problem Name: beecrowd | 1957
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1957
Converting to Hexadecimal
By M.C. Pinto, UNILA Brazil
Timelimit: 1
Data stored in computers are in binary. An economic way of visualizing these numbers is the usage of base 16 (hexadecimal).
Your task is to write a program that, given a natural number at base 10, shows its representation in hexadecimal.
Input
The input is a positive integer number V at base 10 (1 ≤ V ≤ 2 x 109).
Output
The output is the same number V at base 16 in a single line (don't forget the end-of-line character). Use uppercase letters, as shown in the examples.
Input Samples | Output Samples |
10 |
A |
15 |
F |
16 |
10 |
31 |
1F |
65535 |
FFFF |
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
int main()
{
int hex;
cin >> hex;
printf("%X\n" , hex);
return 0;
}
Copy The Code &
Try With Live Editor
Input
Output
#2 Code Example with Javascript Programming
Code -
Javascript Programming
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const { parse } = require("path");
let v = parseInt(input);
console.log(v.toString(16).toUpperCase());
Copy The Code &
Try With Live Editor
Input
Output