Read the below and answer the questions that below:
int fact=1; n=6;
do
{
fact*=n;
}
while (++n<9);
i) How many times does the loop execute? [2]
ii) What is the value of n and fact out of the loop?[2]
Answers
Answered by
1
Explanation:
The outer loop executes 2 times and each time the outer loop executes the inner loop executes 3 times so this will print 2 * 3 = 6 stars. The formula for calculating the number of times the inner loop executes is the number of times the outer loop repeats multiplied by the number of times the inner loop repeats.
Similar questions