The source code to print the hexadecimal number of a given decimal number is given below. The given program is compiled and executed successfully.
// Rust program to print the hexadecimal number
// of a given decimal number
fn main()
{
let num:i8 = 10;
println!("Hexadecimal number is: {:#02X}", num);
}
Output:
Hexadecimal number is: 0xA
Explanation:
Here, we created an 8-bit integer variable num with an initial value of 10. Then we printed the corresponding hexadecimal number using ":#02X" format specifier in println!() macro.
Program/Source Code:
The source code to print the hexadecimal number of a given decimal number is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created an 8-bit integer variable num with an initial value of 10. Then we printed the corresponding hexadecimal number using ":#02X" format specifier in println!() macro.
need an explanation for this answer? contact us directly to get an explanation for this answer