0

How can I manage to resolve Popsicles challenge in C, using ternary operator (conditionnal expression) ?

Here is one of my attempts to solve this, using ternary operator. Comment part with // is working correctly. I just tried to do it another way, using conditionnal expression (y = (x >= 5) ? 5 : x;) as it's demonstrated in Sololearn C course. Please give me hints first rather than the exact solution. https://code.sololearn.com/cPXUwQSvb3Uz/?ref=app

30th May 2021, 9:02 PM
Delorme
4 Antworten
+ 3
You used the ternary correctly. It's just that the type of res is not correct because you cannot assign an array of characters to another array of characters like that. My hint: Arrays in C really like to decay into what?
30th May 2021, 9:42 PM
Dennis
Dennis - avatar
+ 1
I made a few changes, and this solution works. https://code.sololearn.com/cLvveNU9t5bB/?ref=app
30th May 2021, 10:20 PM
Jan
Jan - avatar
0
Thank you for your hint Dennis , I just get back to the lesson and finally find the solution !
31st May 2021, 5:09 PM
Delorme
0
Thank you Quantum, I found the solution and compare my code to yours. I still have some improvements to do !
31st May 2021, 5:14 PM
Delorme