0
Why the output here is 0 not 25?
#include <iostream> using namespace std; int main() { int b=5; for (int i=0;i<6;i++){ b*=i; } cout<< b; return 0; }
4 Réponses
+ 1
Does it multiply all the answers? Like
5*0=0;
5*1=5;
5*2=10;
5*3=15;
5*4=20;
5*5=25;
0*5*10*15*20*25=0
?
+ 1
Aha, got it, thanks :-)
0
i = 0
5*0= 0;
and so on..
start with
i = 1;
0
b*=5;
is b = b*5!
So every time
0 = 0*1;
0 = 0*2;
.....
...
Got it?