Pages

Subscribe:

Blogger templates

Friday, March 9, 2012

Call by Reference


The code starts from next line :
---------------------------------------------------------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
void swap(int &a,int &b);
void main()
{
clrscr();
int a,b;
cout<<"\nEnter the value of a:";
cin>>a;
cout<<"\nEnter the value of b:";
cin>>b;
swap(a,b);
cout<<"\nReplace value of a:"<<a;
cout<<"\nReplace dvalue of b:"<<b;
getch();
}
void swap(int &a,int &b)                                                                       // Function starts here
{
int c;
c=a;                                                                                                     //Swapping code
a=b;
b=c;

}




0 comments:

Post a Comment