The source code to access members of tuple one by one is given below. The given program is compiled and executed successfully.
// Rust program to access members of tuple
// one by one
fn main() {
let MyTuple:(i32,&str,u8) = (101,"Dhairya Pratap",25);
println!("Employee Information: ");
println!("\tEmployee Id : {}",MyTuple.0);
println!("\tEmployee Name: {}",MyTuple.1);
println!("\tEmployee Age : {}",MyTuple.2);
}
Output:
Employee Information:
Employee Id : 101
Employee Name: Dhairya Pratap
Employee Age : 25
Explanation:
Here, we created a tuple MyTuple that contains employee information. Then we accessed the members of MyTuple and printed the employee information.
Program/Source Code:
The source code to access members of tuple one by one is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we created a tuple MyTuple that contains employee information. Then we accessed the members of MyTuple and printed the employee information.
need an explanation for this answer? contact us directly to get an explanation for this answer