Exercise: Swap Two Numbers Using Pointers
Write code to solve the problem.
Question
Write a C program that swaps the values of two integers using pointers.
Create a function named swap() that takes two pointers to integers and swaps their values. Your program should print the values before and after swapping.
Expected output:
Before swap: a = 5, b = 10After swap: a = 10, b = 5
Exercise: Swap Two Numbers Using Pointers
Write code to solve the problem.
Question
Write a C program that swaps the values of two integers using pointers.
Create a function named swap() that takes two pointers to integers and swaps their values. Your program should print the values before and after swapping.
Expected output:
Before swap: a = 5, b = 10After swap: a = 10, b = 5