Practical # 7
/* Write a program for swapping of two numbers using call by value and call by reference strategies. */
#include<stdio.h>
#include<conio.h>
void swap_ref(int*,int*);
void swap_value(int,int);
void main()
{
int a,b,c;
clrscr();
printf("Enter two no.=");
scanf("%d%d",&a,&b);
swap_value(a,b);
swap_ref(&a,&b);
getch();
}
void swap_value(int x,int y)
{
int z;
z=x;
x=y;
y=z;
printf("The value swap using call by value=%d%d",x,y);
}
void swap_ref(int *x,int *y)
{
int z;
z=*x;
*x=*y;
*y=z;
printf("\nThe value swap using call by value=%d%d",*x,*y);
}
Output:-
Enter two no.=7
8
The value swap using call by value=87
The value swap using call by value=87
hey plz post output screenshots...
ReplyDeleteHi Arti,
DeleteAdding images for is not much good, but you can capture output of the program with Windows 7 or later "Snipping Tool".. Hope you will make this your own..