0

Tad bit confused as to why I'm receiving an expected expression error. I've looked at other questions for help on this, but the solution seems to be the curly braces. I've actually done this, and I'm still having problems. Here is the relevant code below.

void sort(int values[], int n)
{
 //uses bubble sort to complete the problem, given that there is only two starting values to work with
 for (int i = 0; i <= n; i++)
 {
  for (int j = 0; int j <= n-i - 1; j++)
  {
   if (values[j] > values[j + 1])
   {
    int replacement = values[j];
    values[j] = values [j + 1];
    values [j + 1] = replacement;
   }
  }
 }
 return;
}

I'm fully aware of what the code is supposed to do, and what I'm trying to accomplish, but I'm still confused as to why this error continues to occur. Help would be appreciated. In the meantime, I'm going to see if I can fix this myself.

3
  • If you are getting that error with the function signature line, the first line posted above, I would look very carefully at the code that precedes this function for a missing curly brace or parenthesis. – Cliff B Jul 21 '16 at 21:14
  • I think I may have figured it out. Give me a minute. UDPATE: Figured it out. Seems I overlooked a major problem in that I listed int twice. – jayfeather31 Jul 21 '16 at 21:21
  • it happens. Good that you found the problem! Please add an answer (self-answers are encouraged) and accept it to remove from the unanswered question pool. (the system will probably make you wait 2 days to accept. ) – Cliff B Jul 21 '16 at 21:25
0

Figured out the problem. The problem here is that int is listed twice, so the program expects an expression when one does not exist in the program itself.

You must log in to answer this question.

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