Can you help me correct my code? Using C (loops). 🙏🏻 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can you help me correct my code? Using C (loops). 🙏🏻

In the song "Twelve days of Christmas", the person's true love gave her gifts everyday, following the pattern: in the first day he gave a partridge in a pear tree, in the second day he gave 2 turtle doves plus a partridge in a pear tree again, in the third day he gave 3 gifts plus all the preceding presents, and so on. Create an algorithm that will compute for the total gifts given by the true love to the person from the first day to the twelfth day of Christmas. https://code.sololearn.com/cF1jvpPBqTuX/?ref=app

20th Oct 2019, 5:31 AM
Glezy
Glezy - avatar
4 Answers
+ 1
It turned out to be pretty easy. Please try to understand the code for yourself ;) https://code.sololearn.com/c0M1iyMQ4Zw5/?ref=app
20th Oct 2019, 10:03 AM
AngryBlackSheep
AngryBlackSheep - avatar
+ 2
https://code.sololearn.com/cAu4N5armZ08/?ref=app
20th Oct 2019, 7:48 AM
AngryBlackSheep
AngryBlackSheep - avatar
0
I could make a version that shows the gifts each day, but I don’t quickly see a way to do that with a short program.
20th Oct 2019, 7:56 AM
AngryBlackSheep
AngryBlackSheep - avatar
0
That'd be great. It'll be fine even if it's long.
20th Oct 2019, 7:58 AM
Glezy
Glezy - avatar