write a function to swap an array a[5] elements like a[0] as
a[5],a[1] as a[4],....a[5] as a[0].without using more than
one loop and use one array not to use temp array?
Answer Posted / ashutosh tiwari
void arr_rev(int *arr, int size)
{
int i;
for(i=0;i<(size/2);i++)
{
if(i==size/2)
break;
*(arr+i) = *(arr+i) + *(arr+(size-i-1));
*(arr+(size-i-1)) = *(arr+i) - *(arr+(size-i-1));
*(arr+i) = *(arr+i) - *(arr+(size-i-1));
}
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How to set file pointer to beginning c?
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
What are the string functions? List some string functions available in c.
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
Are pointers integer?
How can I prevent another program from modifying part of a file that I am modifying?
Can we access array using pointer in c language?
Why is c so popular?
When the macros gets expanded?
Define and explain about ! Operator?
Why c is procedure oriented?
Explain how can I avoid the abort, retry, fail messages?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
What is the argument of a function in c?
Are the expressions * ptr ++ and ++ * ptr same?