0

Solo learn compiler for C giving false or wrong output.

I have tried to compile a C program today via solo learn online compiler. What I have found that it is generating wrong output. For the attached code in my linux pc I have got the result is '72' for the input (lower = 1, upper = 9, operator = +3. The same code is generating '1479' in the solo learn compiler. I am preety sure that the result 72 is correct and solo learn compiler showing wrong output. Admins please take a look at this issue. https://code.sololearn.com/ctQvVijk4hom/?ref=app

20th Apr 2018, 12:54 AM
Mohammad Nazmul Hossain
Mohammad Nazmul Hossain - avatar
5 Antworten
+ 5
Line 26 assigns beyond the arr allocation overwriting result.
20th Apr 2018, 2:18 AM
John Wells
John Wells - avatar
+ 2
char arr[3]; not char arr[2]; You need enough space to put the end of string marker into.
20th Apr 2018, 1:38 AM
Emma
+ 1
Use debugger in code blocks to see if you have any bugs to fix.
20th Apr 2018, 1:03 AM
Akib
Akib - avatar
+ 1
Thank you John Wells . I have found out my mistake. Now I converted the string of arr [ ] to integer by substracting it by 48. Now the code is working fine.
20th Apr 2018, 9:05 AM
Mohammad Nazmul Hossain
Mohammad Nazmul Hossain - avatar
+ 1
well done
20th Apr 2018, 4:11 PM
Sadik Sikder
Sadik Sikder - avatar