The source code to create string literals is given below. The given program is compiled and executed successfully.
// Rust program to create string literals
fn main() {
let name:&str ="rocky";
let company:&str="includehelp";
let address:&str="New Delhi India";
println!("Name : {}",name);
println!("Company Name : {}",company);
println!("Address : {}",address);
}
Output:
Name : rocky
Company Name : includehelp
Address : New Delhi India
Explanation:
Here, we created 3 string literals using &str type. Then we printed the values of created string literals.
Program/Source Code:
The source code to create string literals is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created 3 string literals using &str type. Then we printed the values of created string literals.
need an explanation for this answer? contact us directly to get an explanation for this answer