The source code to create a variable with hexadecimal value and print it in a decimal number is given below. The given program is compiled and executed successfully.
// Rust program to create a variable with
// hexa-decimal value and print it in
// decimal number
fn main() {
let mut num:i32=0x400;
println!("Decimal number: {}",num);
}
Output:
Decimal number: 1024
Explanation:
Here, we created a variable num initialized with a hexadecimal number. Then we printed the corresponding decimal number.
Program/Source Code:
The source code to create a variable with hexadecimal value and print it in a decimal number is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created a variable num initialized with a hexadecimal number. Then we printed the corresponding decimal number.
need an explanation for this answer? contact us directly to get an explanation for this answer