Results 1 to 3 of 3

Thread: Function Swap

  1. #1
    Junior Member
    Join Date
    Apr 2008

    Function Swap

    How do you write a function swap for C++?

  2. #2

    Re: Function Swap

    Hello, Either if it is in C or C++ you can use the best logic as given below:

    if a and b are the values (integer/float/....), then inside function if you use,
    The values of a and b gets swaped.

    The protype for a simple function fname is given below:
    void fname(int*,int*);

    While calling the function you have to pass the address of the values to be swaped as arguments.
    The definition is given below:
    fname(int *p,int *q)

  3. #3
    Junior Member
    Join Date
    May 2008

    Re: Function Swap

    void Swap(int &a, int&b)

  4.  Sponsored Ads


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.