Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to swap two numbers using function and pointers.
- #include<iostream.h>
- #include<conio.h>
- void swap(int*,int*);
- void main()
- {
- clrscr();
- int a,b,c;
- cout<<"Enter one numbers: ";
- cin>>a;
- cout<<"Enter second number: ";
- cin>>b;
- swap(&a,&b);
- cout<<a<<" "<<b;
- getch();
- }
- void swap(int *a,int *b)
- {
- int *c;
- *c=*a;
- *a=*b;
- *b=*c;
- }
Advertisement
Add Comment
Please, Sign In to add comment