Problems With Your Code
I had a look at your code and discovered a few problems.
Missing Opening Curly Brace
In your (1st) for loop your missing the the opening curly brace ({), hence the code does not compile.
Nothing Changes
When the above problem is fixed and the code runs the expected output is not the list of numbers backwards (that's what you're after, right?), but the original list, the numbers in the same order.
Why is that?
The problem is that when you loop through your numbers to swap them from the beginning (i) with the end (j) you keep doing it until i reached the end and j the beginning. Which means, you swapped
- 0 with 9,
- 1 with 8,
- 2 with 7,
- 3 with 6,
- 4 with 5
and instead of stopping here, you kept going and you swapped again
- 5 with 4,
- 6 with 3,
- 7 with 2,
- 8 with 1,
- 9 with 0.
And swapping twice leaves everything in place as if nothing happened.
So the right thing to do is stop at halfway down the array. ;)
A Solution
Here's a fixed solution to the problem:
#include <stdio.h>
int main()
{
int ara[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
int temp, i, j;
for (i = 0, j = 9; i < 5; 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;
}