how to swap two nubers by using a function with pointers?
Answer Posted / reshma
void swap(int *a, int *b)
{
int tmp;
tmp=*a;
*a=*b;
*b=tmp;
}
or
void swap(int *a, int *b)
{
*a=*a^*b;
*b=*a^*b;
*a=*a^*b;
}
| Is This Answer Correct ? | 10 Yes | 1 No |
Post New Answer View All Answers
What happens if a header file is included twice?
What is difference between structure and union in c programming?
How many keywords (reserve words) are in c?
In a header file whether functions are declared or defined?
What are # preprocessor operator in c?
How does normalization of huge pointer works?
What are the two forms of #include directive?
Are c and c++ the same?
Why double pointer is used in c?
When should a type cast be used?
What is the purpose of ftell?
where are auto variables stored? What are the characteristics of an auto variable?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..
What are unions in c?