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 do we declare variables in c?
what will be the output for the following main() { printf("hi" "hello"); }
Write a program of prime number using recursion.
What is a string?
What is c standard library?
What is meant by inheritance?
What are 3 types of structures?
why programs in c are running with out #include
What is data structure in c programming?
Explain the difference between null pointer and void pointer.
Is register a keyword in c?
What are the 4 data types?
Why c is called free form language?
Are comments included during the compilation stage and placed in the EXE file as well?
Write a simple code fragment that will check if a number is positive or negative.