print all the permutaions using recursion : I coded as below to print all the permutaions of three number :1,2,3.

<i><b>But the output is:</b></i><br>
1,1,1<br>
1,1,2<br>
1,1,3<br>
1,2,1<br>
1,2,2<br>
1,2,3<br>
<b><i>the code is as follows:</i></b>

    #include<stdio.h>
    #include<conio.h>
    void perm(int);
    int a[10],l=2;
    int main()
    {int k;
    k=0;
    perm(k);
    getch();
    return 0;}
    void perm(int k)
    {
    int i;
    for(a[k]=1;a[k]<=3;a[k]++)
    {
        if(k==2)
        {
            for(i=0;i<3;i++)
            {
                printf("%d ",a[i]);
            }
            printf("\n");
        }
        else
        {
            k++;
            perm(k);

        }
       }
     }
Pl. give the correct code:)