Friday, September 23, 2011

WAP to swap two numbers using call by reference method


/*
  Name: WAP to swap two numbers using call by reference method
  Author: Parveen Malik
  Date: 23/09/11 11:43
*/


#include <stdio.h>
#include <conio.h>

void swap(int*,int*);


int main()
{
    int x,y;
    printf("Enter the value of x and y \n");
    scanf("%d%d",&x,&y);
    printf("Before swapping\nx = %d\ny = %d\n",x,y);
    swap(&x,&y);
    printf("After swapping\nx = %d\ny = %d",x,y);
    getch();
    return 0;
}


void swap (int *a, int *b)
{
     int temp;
     temp=*a;
     *a=*b;
     *b=temp;
     }


OUTPUT : 


     

1 comments:

Unknown said...

this link might be help you C program to swap two numbers

http://programmergallery.com/c-program/c-program-swap-two-numbers.php

Post a Comment