Rust program to demonstrate the isize and usize datatypes

Here, we are going to demonstrate the isize and usize datatypes in Rust programming language?
Submitted by Nidhi, on September 21, 2021

Problem Solution:

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.

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);


Var1: -10
Var2: 30


Here, we created 2 variables var1, var2 of isize and usize datatype respectively. Then we printed the value of variables using println!() macro.

Rust Basic Programs »

Related Programs

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.