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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    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
1
2
3
4
5
6
7
for(blalba)
{
    for(...)
    {
     ....
    }
}


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


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37


void sortarray(int hiredate[], int employee[], int salary[], int totalRecs);
{
    {
        int temp, end;
        for (end = totalRecs - 1; end&gt;=0; end--)
        {
            for (int count = 0; count &lt; end; count++)
            {
                if(hiredate[count] &gt; hiredate[count +1]
                {
                    temp = hiredate[count];
                    [count] = hiredate[count + 1];
                    hiredate[count + 1] = temp;
                }
            }
            for (int count = 0; count &lt; end; count++)
            {
                if(employee[count] &gt; employee[count +1]
                {
                    temp = employee[count];
                    employee[count] = employee[count + 1];
                    employee[count + 1] = temp;
                }
            }
            for (int count = 0; count &lt; end; count++)
            {
                if(employee[count] &gt; 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
i read your codes and i know your mistakes
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?
a general advice

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.
@Darkmaster Good advice.
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.