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

Why is c faster?

1122


What does p mean in physics?

1052


Write a code to determine the total number of stops an elevator would take to serve N number of people.

1274


Explain how can you tell whether a program was compiled using c versus c++?

1111


Why is extern used in c?

1102


What is int main () in c?

1099


What is new line escape sequence?

1362


All technical questions

1999


Explain how does flowchart help in writing a program?

1131


What is the c language function prototype?

1099


What is the size of enum in c?

1127


What is the purpose of the preprocessor directive error?

1282


What is the use of parallelize in spark?

1035


Explain the term printf() and scanf() used in c language?

1059


What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

1146