Ascending Order of an Array

I tried to make this code to output an array in Ascending Order but the output is showing weird output like 001fgc123 multiple times instead of the array.

What is wrong with my code?
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
38
39
40
41
42
43
44
45
46
47
#include <iostream>

using namespace std;


void ascOrder(int Array[],int length)
{
    int n=0,i,orderNum=0;
    while(n<length)
    {
                      for(i=0;i<length;i++)
                      {
                                           if(Array[i]==orderNum)
                                           {
                                           swap(Array[n],Array[i]);
                                           n++;
                                           }
                      }

                      orderNum++;

    }
}



int main()
{
    int newArray[100],L=0,s;
    cout<<"Enter Array Size: ";
    cin>>L;

    cout<<"\nEnter the Array:"<<endl;
    for(s=0;s<L;s++)
    { cin>>newArray[s]; }

    ascOrder(newArray,L);

    cout<<"\nThe Array in Ascending Order:"<<endl;

    for(s=0;s<L;s++)
    { cout<<newArray<<" "; }

    cout<<endl;

    return 0;
}
line 42: { cout<<newArray[s]<<" "; }
Thanks a lot!

It's so silly of me to not have seen it.
Topic archived. No new replies allowed.