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 do we declare variables in c?

561


what will be the output for the following main() { printf("hi" "hello"); }

9302


Write a program of prime number using recursion.

611


What is a string?

661


What is c standard library?

687






What is meant by inheritance?

625


What are 3 types of structures?

590


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1314


What is data structure in c programming?

567


Explain the difference between null pointer and void pointer.

661


Is register a keyword in c?

629


What are the 4 data types?

592


Why c is called free form language?

566


Are comments included during the compilation stage and placed in the EXE file as well?

664


Write a simple code fragment that will check if a number is positive or negative.

702