Q:

Rust program to demonstrate the isize and usize datatypes

belongs to collection: Rust Basic Programs

0

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.

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 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 var1var2 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

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 a variable with binary valu... >>
<< Rust program to create constants...