I am getting an error message of "expression result unused" for all of my while loops when I try to run the user input through my greedy algorithm. Any thoughts?


Google search of expression result unused will lead to 2 links :

  1. This

    It seems that you have written the number in a wrong way. Have a look at it, you are not supposed to write commas in the numbers. i.e. int i = 50,000 is wrong way and should be written as int i = 50000. Remove any such commas from your program.

  2. This

    Although the link is of for loop but here, re-initialization of the variable used for iterating was not done properly. If variable j is used for iteration, then j+1 is not the way of re-initialization, may be typo could be its reason, it should be j += 1 or j = j+1.

Please specify if any of these 2 worked, if not, then need to see the code. You may cut short the code and not disclose whole of it.

  • Had a similar issue and the second solution was my issue as well. Did not re-initialize.
    – hmitrea
    Jul 29 '19 at 19:14
  • My issue was related to link 2 where I had an incorrect definition of re-initialization. Thanks for the tip @sinister Oct 30 '20 at 21:36

It seems that you define an expression as a result of a computation, and throw it away without assigning it to a variable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .