Advertisement
sahajjain01

Swap two numbers using function.

Aug 26th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. //Program to swap two numbers using function.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. void swap(int&,int&);
  5. void main()
  6. {
  7.     clrscr();
  8.     int a,b,c;
  9.     cout<<"Enter one numbers: ";
  10.     cin>>a;
  11.     cout<<"Enter second number: ";
  12.     cin>>b;
  13.     swap(a,b);
  14.     cout<<a<<" "<<b;
  15.     getch();
  16. }
  17. void swap(int &a,int &b)
  18. {
  19.     int c;
  20.     c=a;
  21.     a=b;
  22.     b=c;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement