0

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?

4
  • That sounds like a compiler error, but you say it happens when you try to run your user input. Can you please clarify step by step exactly where the error occurs?
    – curiouskiwi
    Commented Jun 20, 2014 at 23:07
  • Here are a couple of related questions that might help.
    – Air
    Commented Sep 23, 2014 at 16:07
  • possible duplicate of How to fix the "expression result unused" compilation error?
    – kzidane
    Commented Jun 28, 2015 at 0:58
  • I am a couple of years behind, but it could be because you forgot to return a value from one of your previous functions. Therefore, it did not allow you to run that particular line of code.
    – Veronica
    Commented Feb 8 at 17:25

2 Answers 2

6

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.

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

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 .