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 sequence of instructions that transfers data from memory to an external I/O device by using channel 3 of the 8237 DMA controller. Transfer from 20000H-20FFFH.

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

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

smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

I want Packet capture analysis Project Description: Need assistance in debugging some packet capture Skills required is C Programming

Define the Char Data Type of C Language? The char defines characters. The char type will usually require only 1 byte of internal storage. Every char type has an equivalent inte



Explain structured programming The principal idea behind structured programming was as easy as the idea of "divide and conquer." A computer program could be regarded as having