Wednesday, 7 March 2012

Swap two variable in c using pointer and third or temporary variable

/*Swap two variable using pointer and third variable*/
//here we use pointer to swap value of two variable
#include<stdio.h>
void main()
  {
     int a,b;
     printf("enter the value of a ");
     scanf("%d",&a);
     printf("enter the value of b");
     scanf("%d",&b);
   
 SwapFunc(&a,&b);
     printf("you are chutiya\n \t");
     printf("value of a=%d b=%d",a,b);
  }
void SwapFunc(int *x,int *y)
  {
   int t;
   t=*x;
   *x=*y;
   *y=t;
  }

No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}