# C programming problem - Array

**URL:** <https://forum.freecodecamp.org/t/c-programming-problem-array/344723>\
**Category:** General\
**Created:** [January 26, 2020, 7:03pm UTC](https://forum.freecodecamp.org/t/c-programming-problem-array/344723 "2020-01-26T19:03:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Plabon\_Kumer\_Sarker](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@Plabon\_Kumer\_Sarker](https://forum.freecodecamp.org/u/Plabon_Kumer_Sarker)\
**Post date:** [January 26, 2020, 7:03pm UTC](https://forum.freecodecamp.org/t/c-programming-problem-array/344723/1 "2020-01-26T19:03:59Z")

</div>

I’m trying to alternate array elements high to low sequence.It’s half working correctly and then work normally(low to high).I can’t figure out the problem,Can you please help me?  
My code:

```auto
#include <stdio.h>

int main()
{
    int ara[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
    int i, j, temp;

    for(i = 0,j = 9; i < 10; i++,j--){
        temp = ara[j];
        ara[j] = ara[i];
        ara[i] = temp;
    }

    for(i = 0; i < 10; i++){
        printf("%d\n", ara[i]);
    }
    return 0;
}

```

My output:

```auto
100
90
80
70
60
60
70
80
90
100

Process returned 0 (0x0) execution time : 0.016 s
Press any key to continue.

```

Expected Output should be like:

```auto
100
90
80
70
60
50
40
30
20
10

Process returned 0 (0x0) execution time : 0.016 s
Press any key to continue.

```

---

<div class="post-metadata">

**Author:** ![Plabon\_Kumer\_Sarker](https://avatars.discourse-cdn.com/v4/letter/p/8c91f0/32.png) [@Plabon\_Kumer\_Sarker](https://forum.freecodecamp.org/u/Plabon_Kumer_Sarker)\
**Post date:** [January 26, 2020, 7:17pm UTC](https://forum.freecodecamp.org/t/c-programming-problem-array/344723/2 "2020-01-26T19:17:24Z")

</div>

Actually i fix this by myself,Thank you 🤩

```auto
#include <stdio.h>

int main()
{
    int ara[] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
    int i, j, temp;

    for(i = 0,j = 9; i < 10; i++,j--){
        temp = ara[j];
        ara[j] = ara[i];
        ara[i] = temp;
    }

    for(i = 9; i >= 0; i--){
        printf("%d\n", ara[i]);
    }
    return 0;
}

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 7:37pm UTC](https://forum.freecodecamp.org/t/c-programming-problem-array/344723/3 "2021-06-01T19:37:16Z")

</div>


