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 / 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 |
How can I remove the leading spaces from a string?
how to write a c program to print list of fruits in alpabetical order?
what is the difference between #include<stdio.h> and #include"stdio.h" ?
difference between semaphores and mutex?
Code for calculating square root without using library function, of math.h
Explain what?s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
Describe explain how arrays can be passed to a user defined function
please give me answer with details #include<stdio.h> main() { int i=1; i=(++i)*(++i)*(++i); printf("%d",i); getch(); }
What is meant by type specifiers?
how does a general function , that accepts an array as a parameter, "knows" the size of the array ? How should it define it parameters list ?
Which node is more powerful and can handle local information processing or graphics processing?
What is function pointer and where we will use it