P056.c
Problem Statement
P056.c
WAP to swap the value of a and b using user defined method.
Source Code
c
#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;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
● Author - Amit Dutta · Updated - 12 Dec 2025