0

In for loop for factorial, if the initial value of i is 1 then how can we decrement its value by ++i in dry run?

factorial=factorial*i; for (i=1;i <=n;++i){ cout <<factorial <<endl;}

9th Apr 2017, 3:15 PM
Tehreem
2 Answers
+ 7
Is this an "arrange in correct order" type question? If so, this is the answer. for (i = 1; i <= n; ++i) { factorial = factorial * i; cout << factorial << endl; } The above code prints values from 1! to n!. And, ++i is not decrement. It's increment.
9th Apr 2017, 3:44 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 6
What? Could you explain please? I don't understand what you want...
9th Apr 2017, 3:23 PM
J.G.
J.G. - avatar