+ 4

+SoLvEd+ How to remove wrong approved quiz?

I have posted a quiz and now I believed my answer is not entirely correct. The breakdown : https://code.sololearn.com/cJ4rXBsdnwQs/?ref=app Thanks Omkar for bringing this issue into my attention : https://www.sololearn.com/post/80809/?ref=app

2nd Apr 2019, 8:03 AM
Gordon
Gordon - avatar
15 Respostas
+ 6
Contact info@sololearn.com. I mean, you did answer to this question, but I guess your answer applied to quizzes which haven't been accepted yet? https://www.sololearn.com/Discuss/1712971/?ref=app
2nd Apr 2019, 8:11 AM
Hatsy Rei
Hatsy Rei - avatar
+ 5
It only initializes the array to 0's if it's static or thread storage or use a {} that is smaller than the array itself, which it is neither in the quiz's case.
2nd Apr 2019, 8:48 AM
Dennis
Dennis - avatar
+ 5
int a[10]; // a contains garbage static int a[10]; // static storage, a is all 0's int a[10]{}; // aggregate initialization, a is all 0's int a[10]{ 1,2,3 }; // same as previous, first 3 elements are 1, 2 and 3 and the rest is initialized with 0's thread_local int a[10]; // thread storage, a is all 0's. This is C++ though, not sure the C equivalent.
2nd Apr 2019, 9:02 AM
Dennis
Dennis - avatar
+ 3
Hatsy Rei It is an approved quiz. Thanks for your answer. I will write to sololearn now.
2nd Apr 2019, 8:23 AM
Gordon
Gordon - avatar
2nd Apr 2019, 9:04 AM
Calviղ
Calviղ - avatar
+ 3
~ swim ~ I think if you do {} on an aggregate type it's an aggregate initialization, like with int a[10]{}; list initialization is I think for those types that take an std::initializer_list in it's constructor. Don't quote me on that, I'm not sure either. Confusing for sure, but the C++ standard mentions aggregate initialization "N4594 § 8.5.1 [dcl.init.aggr]". I know it's not C but it's probably the same there.
2nd Apr 2019, 12:25 PM
Dennis
Dennis - avatar
+ 2
Calviղ At step of 3, The array a is not initialized at a[8], it must have displayed 0 when I submitted the quiz. However, it is displaying junk values on my device now. While the key of non assignment is demonstrated, unstable result is wrong result.
2nd Apr 2019, 8:21 AM
Gordon
Gordon - avatar
+ 2
~ swim ~ What does "in global scope" mean?
2nd Apr 2019, 11:47 AM
Gordon
Gordon - avatar
+ 2
~ swim ~ it works too~ wow~ 👏👏👏
2nd Apr 2019, 12:24 PM
Gordon
Gordon - avatar
+ 1
Only for non standard C, it would not initialise unassigned values. So with C standard, your quiz is still correct.
2nd Apr 2019, 8:44 AM
Calviղ
Calviղ - avatar
+ 1
Calviղ I see 36 printed in my code snippet, so sololearn C is non standard C?
2nd Apr 2019, 8:56 AM
Gordon
Gordon - avatar
+ 1
Dennis Can you kindly furnish us with an example for static, thread storage and using {} respectively?
2nd Apr 2019, 8:57 AM
Gordon
Gordon - avatar
0
What's wrong? I think it's a correct answer.
2nd Apr 2019, 8:13 AM
Calviղ
Calviղ - avatar
0
According to this https://stackoverflow.com/a/32708288 C standard would initialise all unassigned arithmetic values to zeros.
2nd Apr 2019, 8:39 AM
Calviղ
Calviղ - avatar
0
Dennis you're right.
2nd Apr 2019, 8:57 AM
Calviղ
Calviղ - avatar