PROGRAM FOR CALL BY VALUE
//call by value
#include<iostream.h>
#include<conio.h>
void main()
{
void swap(int,int);
int a,b;
clrscr();
cout<<"enter 2 numbers:";
cin>>a>>b;
swap(a,b);
getch();
}
void swap(int x,int y)
{
x=x+y;
y=x-y;
x=x-y;
cout<<"\nx="<<x<<"\ny="<<y;
}
#include<iostream.h>
#include<conio.h>
void main()
{
void swap(int,int);
int a,b;
clrscr();
cout<<"enter 2 numbers:";
cin>>a>>b;
swap(a,b);
getch();
}
void swap(int x,int y)
{
x=x+y;
y=x-y;
x=x-y;
cout<<"\nx="<<x<<"\ny="<<y;
}

Comments
Post a Comment