### Function Problem

This is a function I am working on, I think I messed up my brackets but idk where and what I should do. HELP!

 ``12345678910111213141516171819`` `````` void sortarray(int hiredate[], int employee[], int salary[], int totalRecs); { { int temp, end; for (end = totalRecs - 1; end >= 0; end--) { for (int count = 0; count < end; count++) { if (hiredate[count] > hiredate[count + 1] { temp = hiredate[count];[count] = hiredate[count + 1]; hiredate[count + 1] = temp;} } for (int count = 0; count < end; count++) { if (employee[count] > employee[count + 1] { temp = employee[count]; employee[count] = employee[count + 1]; employee[count + 1] = temp;} } for (int count = 0; count < end; count++) { if (employee[count] > employee[count + 1] { temp = employee[count]; employee[count] = employee[count + 1]; employee[count + 1] = temp;} } } }``````
change it in something like this
 ``1234567`` ``````for(blalba) { for(...) { .... } }``````

this way it is easy to see opening and closing brackets
hm still getting the error :| I think i'm blind.

 ``12345678910111213141516171819202122232425262728293031323334353637`` `````` void sortarray(int hiredate[], int employee[], int salary[], int totalRecs); { { int temp, end; for (end = totalRecs - 1; end>=0; end--) { for (int count = 0; count < end; count++) { if(hiredate[count] > hiredate[count +1] { temp = hiredate[count]; [count] = hiredate[count + 1]; hiredate[count + 1] = temp; } } for (int count = 0; count < end; count++) { if(employee[count] > employee[count +1] { temp = employee[count]; employee[count] = employee[count + 1]; employee[count + 1] = temp; } } for (int count = 0; count < end; count++) { if(employee[count] > employee[count +1] { temp = employee[count]; employee[count] = employee[count + 1]; employee[count + 1] = temp; } } } } ``````
Last edited on
line 11,20 and 29 are missing ")"

also you're missing "}" at the end or remove "{" in line 5
Last edited on
these are sintax errors!
you should close all blocks at the end of function
you should close all prenthisses at the end of the if, while statements
and after that what errors the compiler gives to you?
What compiler do you use?

if you write a loop or if statement or anything else using brackets.
write the opening and closing bracket first and then fill it with code, this way you never forget a closing bracket and you dont sit there debugging and looking for errors.
Yes it's correct
my mean isn't arrays
for example
if(expression[])
{
codes;
}
you should close prenthesses after the expression like loops
Line 7 `for (end = totalRecs - 1; end&gt;=0; end--)` The test expression is invalid. In fact you have 4 expressions in there.
also, remove the semi-colon at line 3
Last edited on
Topic archived. No new replies allowed.