Q:

Rust program to convert an integer into a string

belongs to collection: Rust Basic Programs

0

In this program, we will convert an integer number into the string using the to_string() function and print the result.

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 convert an integer into the string is given below. The given program is compiled and executed successfully.

// Rust program to convert an integer
// into a string

fn main() 
{
    let mut intVar:i32 = 108;
    let mut strVar=intVar.to_string();
    
    println!("String is : {}",strVar);
}

Output:

String is : 108

Explanation:

Here, we created a variable intVar of i32 type. Then we assigned the value of intVar variable into &str variable using to_string() function. After that, we printed the result.

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 calculate the power of float numbe... >>
<< Rust program to convert a string into float...