+ 2

Help with understanding the answer

I'm studying for CLE – C Certified Entry-Level Programmer certification. One of the model test question is: #include <stdio.h> int main(void) { int i, t[4] = {1, 2, 4, 8}; for (i = 0; i < 2; i++) t[i] = t[3 - i]; printf("%d", t[2]); return 0; } My result was 4, with following logic: t[0]=1-> 8, t[1]=2->4, t[3] and t[4] are unchanged as i should be lower than 2. However the test expects result of 1, like if the conditiom "i<2" wasn't there. Am I making a mistake?

26th Jul 2024, 11:15 AM
Lubos Comor
6 Respuestas
0
PS. I tried ChatGPT to help me but it says my answer is correct.
26th Jul 2024, 11:15 AM
Lubos Comor
0
Is it possible for anyone to view the problem without signing up for the certification? if so, can you please attach link to the page describing the problem. This is in order for verification purposes only. I also would say you were right given the snippet shown was legit as shown in the problem's page.
26th Jul 2024, 11:55 AM
Ipang
0
You need to register (free account) on edube.org. It's one of the questions from Module4 C Essentials. The questions are randomized each time you take the test so I can't post exact link, just screenshot.
26th Jul 2024, 12:00 PM
Lubos Comor
0
It seems right to me as well. I even tested it on C++, the result was 4. Try asking your prof/mentor regarding your concern. Run it on IDE and show him/her the result.
26th Jul 2024, 2:08 PM
Pat
0
@Lubos Comor Try contacting them (edube.org) to notify them about this. Had this been true, they should fix it, if they care about their contents and reputation as certificate issuer. SoloLearn Discuss forum has its own scope about topics to discuss I'm sure you understand that - SoloLearn and edube.org are not related thus discussing edube.org related stuffs here feels somewhat irrelevant :) I stood by the point that your answer be correct while the problem (in test) is genuine as you described.
27th Jul 2024, 4:46 AM
Ipang
0
Ipang Thank you for answer.
27th Jul 2024, 5:47 AM
Lubos Comor