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


Please Help Members By Posting Answers For Below Questions

Explain how does flowchart help in writing a program?

617


what is stack , heap ,code segment,and data segment

2208


What is wrong with this statement? Myname = 'robin';

810


a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if

695


How can I direct output to the printer?

805






Explain the advantages of using macro in c language?

567


What is the difference between void main and main in c?

614


cavium networks written test pattern ..

3584


What is c language used for?

551


which is conditional construct a) if statement b) switch statement c) while/for d) goto

729


Explain how do you determine whether to use a stream function or a low-level function?

616


Explain low-order bytes.

617


What is the difference between the = symbol and == symbol?

617


What are the 5 data types?

592


In which language linux is written?

595