Monday, June 18, 2012

To swap two numbers using functions (Call by value)


/* Program to swap two numbers using call by value */

#include<stdio.h>

#include<conio.h>

void swapv(int x,int y);

void main()

{

  int a=10,b=20;

  clrscr();

  swapv(a,b);

  printf("\na=%d and b=%d",a,b);

  getch();

}

 

void swapv(int x,int y)

{

  int temp;

  temp=x;

  x=y;

  y=temp;

  printf("\nx=%d and y=%d",x,y);

}

 

OUTPUT

 

x=20 and y=10

a=10 and b=20

 

No comments:

Post a Comment

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