Sololearn's compiler mistake! | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Sololearn's compiler mistake!

Hello everyone! In the C++ course, while solving the second code project, I believed I solved the problem correctly however my output and the expected output weren't matching. I was a bit surprised and as a result, I copied the same exact code and tried different online compilers and Vscode too, my output there matched the expected output which after entering the number(11<18<29<33<44) must return 44.5 because 11% off from 50. But in Sololearn, my output is 49 always regardless of the input and I then realised that the variable min is always =2(only on sololearn) I have no idea why! So was it a coincidence or is it a mistake from the sololearn's compiler? (I tried all the visible test cases in vscode and they all worked normally and returned the expected output). https://sololearn.com/compiler-playground/cPCDykJwQbOz

8th Dec 2022, 8:31 PM
TOURE GRANDIZER
TOURE GRANDIZER - avatar
3 Antworten
+ 8
TOURE GRANDIZER , can you please link your code here so that we are able to figure out what the issue is? > please also mention the exercise name / number.
8th Dec 2022, 8:40 PM
Lothar
Lothar - avatar
+ 6
It is NOT a compiler mistake. Different compilers may slightly vary in how they treat uninitialized values and how "strict" they are. If you initialize your array as int ages[5]; you have not assigned any value to ages[0] yet. You need to set ages[0] = 0; ***before*** int min = ages[0]; (Or simply initialize int min = 0)
8th Dec 2022, 8:59 PM
Lisa
Lisa - avatar
+ 1
TOURE GRANDIZER That's a garbage value 2, i think actually.. Assign min = ages[0] after taking input into ages[0]; Else set min = Integer_max or if your inputs don't have negetive values, then set min= -1 ; a negetive value....
9th Dec 2022, 9:46 AM
Jayakrishna 🇮🇳