+ 3

[SOLVED] Questionable answer of a C challenge

Here the code of the question in the challenge https://code.sololearn.com/cVAI3XovBUHE/?ref=app To answer the question, you had to enter the number that would have been printed by the program. The correct answer for the challenge is 0. However since the array is uninitialised and the program doesn't modify a[8] the output should be a random number saved in the memory. Am I missing something?

18th Oct 2020, 5:42 PM
Davide
Davide - avatar
8 Respostas
+ 2
Chaithra Gowda👑 Avinesh I uploaded the screenshot of the challenge on the WWW so that you can see: https://ibb.co/rpJgqdZ edit: lol I can make my own answer the best one🤣
18th Oct 2020, 6:14 PM
Davide
Davide - avatar
+ 6
You are right it's printing garbage value which changes often randomly ,but correct answer is not 0 it's also a garbage value!
18th Oct 2020, 5:51 PM
chaithra Gowda
chaithra Gowda - avatar
+ 2
Make sure to initialize an array before you use it or else just like Chaithra Gowda👑 mentioned, it will print garbage values. a[10] = {}; should do.
18th Oct 2020, 5:56 PM
Avinesh
Avinesh - avatar
+ 1
Davide The creator of the challenge might have thought that the array elements gets initialized to 0 by default, which is not in this case.
18th Oct 2020, 6:21 PM
Avinesh
Avinesh - avatar
+ 1
Avinesh use your Mod powers to make him initialize the array if you please
18th Oct 2020, 6:24 PM
Davide
Davide - avatar
+ 1
NotAPythonNinja thank you for the info
18th Oct 2020, 6:25 PM
Davide
Davide - avatar
+ 1
Davide unfortunately I cannot do that but you can report that question by clicking on the icon on top right and it might be reviewed.
18th Oct 2020, 6:28 PM
Avinesh
Avinesh - avatar
+ 1
Avinesh yes I did it when I saw the challenge results. Reviewed by a more powerful Mod? You don't need to answer that, I do like to think that there's a secret order of ancient and powerful Mods ruling the Internet. Leave me in my lies.
18th Oct 2020, 6:42 PM
Davide
Davide - avatar