What you are doing gives this result if you print temp1 and a[i] in that loop

temp1: abcba
a[i]: ebcbe

You are in no way reversing an array.

Next time, please try to write down in simple english what you want to do (meaning an algorithm) and then try again. Do not simply try to use bits and pieces from everywhere such as exchange used in sorting. No matter, here's a better way:


Code: C++
</p>
<p> a[b]='\0';</p>
<p> for (int i = 0; i < b; i++)</p>
<p> {</p>
<p> temp1[i] = a[b-i-1];</p>
<p> cout<<temp1[i];</p>
<p> }</p>
<p>