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
Consider the following example: int max(int x, int y)                  {                                 return ( x > y) ? x : y ;                  }   float max

Syntax rules for writing a destructor function Its name is the similar as that of the class to which it belongs, except that the first character of the name is the symbol t

how to make a game

Description: Create a program that allows the user to track the hours an employee worked in a week. How much the employee was paid and any extra hours worked (overtime pay).

Deliverables: you are required to upload your c code in the assignment dropbox set in Moodle. You are supposed to work with Linux gcc compiler and pico editor for compiling via the

write a program that counts the number of occurances of the string in the n-th padovan string p(n)

Develop a Student class that has the following header file: #ifndef STUDENT_H #define STUDENT_H #include #include #include using namespace std; class Stu

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

what are 3 conditions under which the sequential search of a list is preferable to binary search?

Should I call a destructor explicitly on a local variable?