Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
When the output seemingly matches the correct answers, but is not verified, that usually means you are somewhere printing "invisible" characters (characters without a console representation) that make the comparison fail. However, since you mentioned the first chapter, I remember cases where people had issues with the proper formatting in "Roses are red, Violets are blue". But without more details, this is hard to tell. It would be best if you could include your code in the question, alongside what exercise you are referring to (and if it is PRO, preferably a short description too, as a lot of users won't be able to access it).
28th Jan 2021, 2:18 AM
Shadow
Shadow - avatar
+ 2
Ah yes, I see. Your calculations are correct. What you have to realize is that your answers are evaluated by a machine, which is unable to interpret your answer the way a human could. That is why it expects your output in a certain format. If you review the sample output, it only wants you to print the resulting number, and nothing else. Unfortunately, printing anything else, like "Total Empty Seats ", will mess up the comparison between your output and the correct solution. Therefore, you need to make sure your output matches exactly, not only partially.
29th Jan 2021, 9:09 AM
Shadow
Shadow - avatar
+ 1
Because you are assigning 0 to "remainder", not comparing the values. Comparison is done via the == operator: https://www.sololearn.com/learning/1612/ Right now, the return value of the assignment, which is 0, is checked, and 0 is always false, hence the conditional never executes.
30th Jan 2021, 8:47 AM
Shadow
Shadow - avatar
+ 1
There are three issues you need to correct: 1. Typo in the last output: "ticketPrices" instead of "ticketPrice". 2. Declaring 'i' again in the loop will shadow the 'i' declared in main(). Therefore, that 'i' will still equal 0 after the loop has ended, because the local one has been incremented instead. I'd say you don't really need "ticketPrice" and 'i' in main(), you could just use the value 50 at the end. 3. Dividing an integer by another integer will yield an integer (decimal part is truncated) in C++. Therefore, for any values < 100, the division at the end will equal 0. At least one of the operands should be a floating point value to get a decimal value.
4th Feb 2021, 9:26 AM
Shadow
Shadow - avatar