call by value in c example,call by value program in c,example of call by value
Write a c program to illustrate call-by-value parameter passing technique
#include<stdio.h>
#include<conio.h>
void main()
{
void swap(int,int);
int a,b;
clrscr();
printf("Enter two numbers:\n");
scanf("%d%d",&a,&b);
printf("Before calling the function a=%d and
b=%d\n",a,b);
swap(a,b);
printf("After calling the function a=%d and
b=%d",a,b);
getch();
}
void swap(int x, int y)
{
int temp;
temp=x;
x=y;
y=temp;
}
Output:
Enter two numbers:
2
4
Before calling the function a=2 and b=4
After calling the function a=2 and b=4
Note: In this
program the swapping of numbers does not take place.
No comments: