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
Why is c faster?
What does p mean in physics?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
Explain how can you tell whether a program was compiled using c versus c++?
Why is extern used in c?
What is int main () in c?
What is new line escape sequence?
All technical questions
Explain how does flowchart help in writing a program?
What is the c language function prototype?
What is the size of enum in c?
What is the purpose of the preprocessor directive error?
What is the use of parallelize in spark?
Explain the term printf() and scanf() used in c language?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?