topical media & game development
basic-program-solutions-05-Soln5-2.c
? /
basic-program-solutions-05-Soln5-2.c
// Soln5_2.cpp
include <iostream>
using std::cout;
using std::endl;
// Swap two integers
void swap(int* pa, int* pb)
{
int temp;
temp = *pa;
*pa = *pb;
*pb = temp;
}
int main()
{
int a=6, b=4;
cout << "Before swap:" << endl;
cout << "a = " << a << ", b = " << b << endl;
swap(&a, &b);
cout << "After swap:" << endl;
cout << "a = " << a << ", b = " << b << endl;
return 0;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.