sorting array in ascending order

something is wrong with this code.it prints 10 20 40 50 30.please help

#include “stdafx.h”
#include
#include
using namespace std;

int main()
{
int anarray[5] = {40,10,50,30,20};
for (int iii=0 ; iii <= 4 ; iii++)
{
static int n=anarray[iii];
static int count = 0;
for(int jjj=iii+1 ; jjj <=4 ; jjj++)
continue ;
else
{
n = anarray[jjj];
count = jjj ;
}
}
swap(anarray[iii],anarray[count]);
}
cout << "the ascending order is :" << endl;
for (int kkk=0 ; kkk <=4 ; kkk++)
cout << anarray[kkk] << " " ;

return 0;
}
Here it is indented:
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
#include “stdafx.h”
#include
#include
using namespace std;

int main()
{
    int anarray[5] = {40,10,50,30,20};
    for (int iii=0 ; iii <= 4 ; iii++)
    {
        static int n=anarray[iii];
        static int count = 0;
        for(int jjj=iii+1 ; jjj <=4 ; jjj++)
            continue ;
        else
        {
            n = anarray[jjj];
            count = jjj ;
        }
    }
    swap(anarray[iii],anarray[count]);
}
    cout << "the ascending order is :" << endl;
    for (int kkk=0 ; kkk <=4 ; kkk++)
        cout << anarray[kkk] << " " ;
    
    return 0;
}
As you can clearly see, this is full of problems. This code won't even compile! Try to fix the problems yourself, first.
Topic archived. No new replies allowed.