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