adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

program in c++ to swap two number using call by reference

Program in C++ to swap two number using call by reference


#include<iostream>
#include<conio.h>
 using namespace std;
 void swap(int &,int &);
 int main()
  {
   int a,b;
   cout<<"Enter two numbers:-";
   cin>>a>>b;
   cout<<"Before swapping value of a ="<<a<<" and value of b ="<<b;
   swap(a,b);
   cout<<"\nAfter swapping value of a ="<<a<<" and value of b ="<<b;
   getch();
   return 0;
   }
  void swap(int &x,int &y)
   {
    int temp=x;
    x=y;
    y=temp;
   }
Output:-

Post a Comment

0 Comments