Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Program To Swap Values By Passing Pointers...


 Program to swap two desire integer value , by using pointer and function calling method.

here use of function swap "swap(int *x,int *y)"
which define outside the body of main function .



Source Code:-

#include<iostream.h>
#include<conio.h>
void swap(int *x,int *y);
void main()
{clrscr();
 int a,b;
 cout<<"\tThe program for Swapping using pointers by-VARUN KUMAR\n";
 cout<<"Enter First Value : ";
 cin>>a;
 cout<<"Enter Second Value: ";
 cin>>b;
 swap(&a,&b);
 cout<<"\nSwapped Values\n";
 cout<<"a="<<a<<"and b="<<b<<"\n";
 getch();
}
void swap(int *x,int *y)
{int temp;
 temp=*x;
 *x=*y;
*y=temp;
}

1 comment:

Blogger Widgets

Find Us On Google, Just type - way2cplusplus -

If you have any questions on implementing or understanding this C++ Program , shoot me a comment and I'll be glad to help! :) :)