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; }

13th Jul 2018, 10:13 AM
Yelyzaveta Al-Dara
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 ?
13th Jul 2018, 10:21 AM
Yelyzaveta Al-Dara
+ 1
Aha, got it, thanks :-)
13th Jul 2018, 10:25 AM
Yelyzaveta Al-Dara
0
i = 0 5*0= 0; and so on.. start with i = 1;
13th Jul 2018, 10:16 AM
Akib
Akib - avatar
0
b*=5; is b = b*5! So every time 0 = 0*1; 0 = 0*2; ..... ... Got it?
13th Jul 2018, 10:24 AM
Akib
Akib - avatar