Program of swapping in c++, C/C++ Programming

Program of swapping two varibales:

void swap(int *, int *);   // This is swap's prototype

int main()

{

                int x = 5, y = 7;

                swap(&x, &y);

                cout << "\n x is now "<< x << " and y is now " << y << '\n';

 

                return 0;

}

void swap(int *a, int *b)    // swap is actually defined here

{

                int temp;

                temp = *a;

                *a = *b;

                *b = temp;

}

Posted Date: 10/18/2012 9:25:02 AM | Location : United States







Related Discussions:- Program of swapping in c++, Assignment Help, Ask Question on Program of swapping in c++, Get Answer, Expert's Help, Program of swapping in c++ Discussions

Write discussion on Program of swapping in c++
Your posts are moderated
Related Questions
Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

E x p r e s sion and their types: An expression will be in form of mathematical expression with C++ syntax embedded with it. Expressions are of following types which m

#queWrite a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points c

The program reads two numbers and a character (operator). If the character is "+" then sum is displayed. If it is "-"then difference is displayed. If it is "*" then product is disp

WHAT IS CGI?

Of course it is C[i] = A[i] + B[i].It was a typing mistake,never mind. You just understand the concept. 27-1 b. for grain-size=1 n=A.length grain-size=1 r=n for

The goto statement This statement can be used to branch to another statement of the program. This is rarely used as it violates the principle of structured programming. Though

Compiler Design - Limit In The Method Instructions

Is it possible to create your own header files? - Yes, it's possible to create a customized header file. - To do this, you just need to include function prototypes that you

WAP TO ACCEPT MARKS OF THREE SUBJECT FOR STUDENT & CALCULATE TOTAL MARKS AND PERCENTAGE #include stdio.h> #include conio.h>   void main() {            int M1,M