Thursday, February 12, 2015

C program to swap two numbers using pointers


C++ program to swap two numbers using pointers

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int *a,*b,*temp;
cout<<"Enter value of a and b:";
cin>>*a>>*b;

temp=a;
a=b;
b=temp;

cout<<"
After swaping
a="<<*a<<"
b="<<*b;

getch();
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.