มี 2 วิธีในการสลับค่าตัวแปร 2 ตัว: ใช้ตัวแปรชั่วคราว (temp) และไม่ใช้ตัวแปรชั่วคราว วิธีที่ 1: ใช้ตัวแปรชั่วคราว (temp variable) #include <iostream> using namespace std; int main() { int a = 10, b = 5, temp; temp = a; a = b; b = temp; cout << Value of a is <<