How many times will the inner loop execute in total for this
How many times will the inner loop execute in total for this nested loop: for(int i= 1; i
Solution
Ans> 12
So, for outer loop, the inner loop will run total 12 times. it is clearly shown in the output of the program.
For each value(1 to 4) of outer loop , inner loop will run 3 times. So, total 12 times it will run.
Program:
#include <iostream>
using namespace std;
int main() {
for(int i=1; i<5;i++) //outer loop
{
cout<<\"\ now\"<<i<<\" \";
for(int j=1;j<4;j++) //inner loop
{
cout<<\" j=\"<<i<<j;
}
}
return 0;
}
Output:
now1 j=11 j=12 j=13
now2 j=21 j=22 j=23
now3 j=31 j=32 j=33
now4 j=41 j=42 j=43
