Here, we will create variables using isize and usize data types. isize is a pointer-sized signed integer type and usize is a pointer-sized unsigned integer type.
The source code to demonstrate isize and usize datatype is given below. The given program is compiled and executed successfully.
// Rust program to demonstrate
// isize and usize datatypes.
fn main() {
// The pointer-sized signed integer type
let mut var1:isize=-10;
// The pointer-sized unsigned integer type
let mut var2:usize=30;
println!("Var1: {}",var1);
println!("Var2: {}",var2);
}
Output:
Var1: -10
Var2: 30
Explanation:
Here, we created 2 variables var1, var2 of isize and usize datatype respectively. Then we printed the value of variables using println!() macro.
Program/Source Code:
The source code to demonstrate isize and usize datatype is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created 2 variables var1, var2 of isize and usize datatype respectively. Then we printed the value of variables using println!() macro.
need an explanation for this answer? contact us directly to get an explanation for this answer