PROGRAM TO SWAP TWO NUMBERS BY CALL BY VALUE

//PROGRAM TO SWAP TWO NUMBERS BY CALL BY VALUE//
#include<stdio.h>
#include<conio.h>
void swap(int,int);
void main()
{
int a,b;
clrscr();
printf(“Enter the value of first number: “);
scanf(“%d”,&a);
printf(“Enter the value of second number: “);
scanf(“%d”,&b);
printf(“Value of first number is: %d\n”,a);
printf(“Value of second number is: %d\n”,b);
swap(a,b);
getch();
}
void swap(int a,int b)
{
a=a+b;
b=a-b;
a=a-b;
printf(“\nAfter swapping value of variables are:”);
printf(“value of first number is: %d\n”,a);
printf(“Value of second number is: %d\n”,b);
return;
}

Leave a Reply

Your email address will not be published. Required fields are marked *