void setup() {
// Initialize serial communication at 9600 bits per second:
Serial.begin(9600);
int a = 10;
int b = 20;
// Print original values
Serial.print("Original a: ");
Serial.println(a);
Serial.print("Original b: ");
Serial.println(b);
// Swap values using pointers
swap(&a, &b);
// Print swapped values
Serial.print("Swapped a: ");
Serial.println(a);
Serial.print("Swapped b: ");
Serial.println(b);
}
void loop() {
// Nothing to do here
}
void swap(int *ptr1, int *ptr2) {
int temp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = temp;
}