ADVERTISEMENT
ADVERTISEMENT

Rust program to create a variable with hexadecimal value and print it in the decimal number

Here, we are going to learn how to create a variable with hexadecimal value and print it in the decimal number in Rust programming language?
Submitted by Nidhi, on September 21, 2021

Problem Solution:

Here, we will create a 32-bit signed integer variable with the hexadecimal number and print 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.

// 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.

Rust Basic Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.