Â
In this, we are going to see a program in which it will swap 2 numbers using call by value method in C programming Language.
//WAP to swap 2 numbers using call by value
#include <stdio.h>
int Swap(int num1, int num2)
{
printf("The number before swapping is:\n num1 = %d \n num2 = %d", num1, num2);
num1 = num1 + num2;
num2 = num1 - num2;
num1 = num1 - num2;
printf("\nThe number After swapping is:\n num1 = %d \n num2 = %d", num1, num2);
return 0;
}
void main()
{
int a, b;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
Swap(a, b);
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP