+ 4

What just happened

I wast trying to do a brute force in c++ and this happened https://code.sololearn.com/ceJosWMarl8w/?ref=app Can someone explain me this?

31st Aug 2018, 2:13 PM
I Am Arthur
I Am Arthur - avatar
6 Respostas
+ 5
Arthur you have not done initialization of all three int variable of for loop...also your test should be as below : x[i]+x[i2]+x[i3]
31st Aug 2018, 2:22 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Ketan Lalcheta Yeah, i totally forgot this... Do you have any idea about why this happened?
31st Aug 2018, 2:29 PM
I Am Arthur
I Am Arthur - avatar
+ 2
Ketan Lalcheta Noww its showing no output...
31st Aug 2018, 3:35 PM
I Am Arthur
I Am Arthur - avatar
+ 1
Arthur any uninitialized variable, if not static, gets random value by default.. and additionally, you were not adding char from char array but int only to char
31st Aug 2018, 2:31 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
Ketan Lalcheta [not to distract, just trivia] Uninitialized variables get whatever is in memory at the time. This is not necessarily random, and may even be usefully deterministic. It's still abnormal as an initializer though. :)
31st Aug 2018, 4:53 PM
Kirk Schafer
Kirk Schafer - avatar
0
Damn!!
31st Aug 2018, 2:16 PM
Ramphy Aquino Nova
Ramphy Aquino Nova - avatar