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
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
What is the difference between char array and char pointer?
Why does everyone say not to use gets?
What will the preprocessor do for a program?
Why clrscr is used in c?
What is n in c?
can anyone please tell about the nested interrupts?
Explain that why C is procedural?
Write a program on swapping (100, 50)
I have seen function declarations that look like this
What is structure in c definition?
FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.
What is a volatile keyword in c?
What is the value of uninitialized variable in c?
What is the difference between a function and a method in c?