+ 1
do while loop which solve 1*2*3*.....*20
6 Answers
+ 1
i would suggest using a for loop though, because it's good practice to use a for loop if you know exactly how many repetitions you need:
int sum = 1;
for( int i = 1; i <= 20; i++)
{
sum *= i;
}
0
This is straight forward:
unsigned i = 1;
unsigned result = 1;
do {
result = result * i;
++i;
} while (i < 20+1);
0
you can omit the 20 + 1 with 21 for less calculations
0
Write for,do_while,and while statements to compute the following sums and product.1*2*3*...*20
0
Do while loop which 1*2*3..........*20