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?



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].wit..

Answer / 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

More C Interview Questions

I need previous papers of CSC.......plz help out by posting them.......

0 Answers  


write a c code "if you give a any decimal number then print that number in english alphabet"? ex: i/p: 552 o/p: five hundred fifty two ...

1 Answers   Philips,


main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } what is the output?

9 Answers   Ramco,


Write a program to check whether a number is prime or not using c?

0 Answers  


What is the purpose of 'register' keyword?

0 Answers  


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

0 Answers  


what do you mean by inline function in C?

0 Answers   IBS, TCS,


What is the size of empty structure in c?

0 Answers  


what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }

4 Answers  


How do I read the arrow keys? What about function keys?

0 Answers  


Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?

0 Answers  


how to create c progarm without void main()?

1 Answers   NIIT,


Categories