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

What language is windows 1.0 written?

583


Can we use visual studio for c?

556


What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

631


How do you define a function?

587


Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers

1429






What is identifiers in c with examples?

680


Do you know the difference between exit() and _exit() function in c?

612


Who invented b language?

924


What is the difference between text and binary modes?

650


How do you declare a variable that will hold string values?

672


we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above

643


What are directives in c?

550


How do I get an accurate error status return from system on ms-dos?

653


What is difference between class and structure?

577


Explain how many levels deep can include files be nested?

630