The source code to demonstrate the nested for loop is given below. The given program is compiled and executed successfully.
// Rust program to demonstrate the
// nested for loop
fn main() {
let mut cnt1:i32 = 0;
let mut cnt2:i32 = 0;
for cnt1 in 2..6
{
for cnt2 in 1..11
{
print!("{} ",(cnt1*cnt2));
}
println!();
}
}
Program/Source Code:
The source code to demonstrate the nested for loop is given below. The given program is compiled and executed successfully.
Output:
Explanation:
Here, we used a nested for loop to print tables from 2 to 5.
need an explanation for this answer? contact us directly to get an explanation for this answer