Call by value method in c language.
■ program for swapping two numbers using function
#include<stdio.h>
#include<conio.h>
void swap(int,int);
void main()
{
int a,b;
clrscr();
printf("enter two numbers=");
scanf("%d%d",&a,&b);
swap(a,b);
getch();
}
void swap(int a,int b)
{
int temp;
temp=a;
a=b;
b=temp;
printf("a is=%d\n",a);
printf("b is=%d",b);
}
■》Output->
enter two numbers=4
5
a is=5
b is=4
Comments
Post a Comment