Q:

Rust program to create an alias of built-in data type

belongs to collection: Rust Basic Programs

0

Here, we will create an alias or alternative name of the i32 datatype. Then we will create a variable using an alias name.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to create an alias of built-in data type is given below. The given program is compiled and executed successfully.

// Rust program to create an alias 
// of built-in data type

fn main() {
    type int=i32;
    
    let mut num:int=1024;  
    
    println!("Number: {}",num);
}

Output:

Number: 1024

Explanation:

Here, we created the alias of the i32 data type using the type keyword. Then we created a variable using created alias name and printed the value of the variable.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Rust Basic Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Rust program to create string literals... >>
<< Rust program to create a variable with hexadecimal...