Write a program to swap the value using Call by value.

#include<stdio.h>
#include<conio.h>
void swap(int,int);
int main()
{
int a,b;
printf("enter the value of a");
scanf("%d",&a);
printf("enter the value of b");
scanf("%d",&b);
printf("the value of a before swapping is %d",a);
printf("\nthe value of b before swapping is %d",b);
swap(a,b);
printf("\nthe value of a after swapping is %d",a);
printf("\nthe value of b after swapping is %d",b);
}
void swap(int a,int b)
{
int temp;
temp=b;
b=a;
a=temp;
}

No comments:

Post a Comment