p056.c
Problem Statement
WAP to swap the value of a and b using user defined method.
| Property |
Detail |
| Author |
Amit Dutta (amitdutta4255@gmail.com) |
| License |
MIT |
Actions
Raw View on GitHub
💡 You can print or save this file by opening Raw and using your browser.
Source Code
#include <stdio.h>
void swap(int *a, int *b)
{
int temp = *a;
*a = *b;
*b = temp;
}
int main()
{
int a, b;
printf("Enter A and B: ");
scanf("%d %d", &a, &b);
printf("\nBefore swap A: %d, B: %d", a, b);
swap(&a, &b);
printf("\nAfter swap A: %d, B: %d", a, b);
return 0;
}