/* This is the thirteenth lab of Lab EE107
The purpose of this lab to illustrate swapping of content in address of pointers
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: April 23rd, 2024.
*/
#include <stdio.h>
// Function to swap two integers using pointers
void swap_EU(int *px_EU, int *py_EU) {
int temp_EU;
// Swap values
temp_EU = *px_EU; // Store the value pointed by px
*px_EU = *py_EU; // Assign the value pointed by py to px
*py_EU = temp_EU; // Assign the stored value (initially pointed by px) to py
}
int main() {
// Declaration of variables
int a_EU = 1, b_EU = 2;
// Call swap function to interchange values of a and b
swap_EU(&a_EU, &b_EU);
// Printing the values of a and b after swapping
printf("a=%i, b=%i", a_EU, b_EU);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: