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

wht is the difference between KPO and BPO ?

2 Answers   Accenture, BPO, HCK, HCL, Infosys,


Heyyy All, Just a challenge . A C program with if Else if(){ /// insert sumthing print ("in if") // insert sumting } else { ///// insert sumthing print ("in else"); //// insert sumthing } can anyone modify it so that program prints. if and else both

3 Answers  


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

0 Answers   TISL,


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

0 Answers  


What is the difference between a free-standing and a hosted environment?

0 Answers   Aspire,






Differentiate between new and malloc(), delete and free() ?

0 Answers   iNautix,


What are local static variables?

0 Answers  


Which node is more powerful and can handle local information processing or graphics processing?

0 Answers  


i want to know aptitude questions,technical questions

2 Answers  


4.weight conversion: Write a program that will read weight in pounds and convert it into grams.print both the original weight and the converted value.There are 454 grams in a pound.design and carry out a test plan for this program.

1 Answers   Wipro,


Why is c so powerful?

0 Answers  


How do you print only part of a string?

0 Answers  


Categories