Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How to set file pointer to beginning c?

1203


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?

1506


What are the string functions? List some string functions available in c.

993


#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); }

1123


Are pointers integer?

1020


How can I prevent another program from modifying part of a file that I am modifying?

1062


Can we access array using pointer in c language?

1096


Why is c so popular?

1165


When the macros gets expanded?

1428


Define and explain about ! Operator?

1003


Why c is procedure oriented?

1081


Explain how can I avoid the abort, retry, fail messages?

1059


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

1118


What is the argument of a function in c?

1053


Are the expressions * ptr ++ and ++ * ptr same?

1158