do while loop which solve 1*2*3*.....*20 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

do while loop which solve 1*2*3*.....*20

20th Jun 2016, 12:01 PM
Heka Hunduma Banja
Heka Hunduma Banja - avatar
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; }
21st Jun 2016, 7:06 AM
MaxCode
0
This is straight forward: unsigned i = 1; unsigned result = 1; do { result = result * i; ++i; } while (i < 20+1);
20th Jun 2016, 12:34 PM
Stefan
Stefan - avatar
0
you can omit the 20 + 1 with 21 for less calculations
21st Jun 2016, 10:41 AM
Klodian Lula
Klodian Lula - avatar
0
Write for,do_while,and while statements to compute the following sums and product.1*2*3*...*20
12th Jan 2023, 8:10 AM
Andebet haile
Andebet haile - avatar
0
Do while loop which 1*2*3..........*20
20th Jan 2024, 10:18 AM
Kamil Naje
Kamil Naje - avatar
0
Mpmqo
29th Jan 2024, 9:10 AM
Abiyot Tesfaye
Abiyot Tesfaye - avatar