-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCallByReference.c
More file actions
31 lines (31 loc) · 915 Bytes
/
CallByReference.c
File metadata and controls
31 lines (31 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h>
void main()
{
void swap(int *,int *);
int a,b;
scanf("%d%d",&a,&b);
printf("In Main function Before swaping \n");
printf("The Value of A=%d B=%d\n",a,b);
printf("Address of A and B %d %d",&a,&b);
swap(&a,&b);
printf("\n\nIn Main function After swaping \n");
printf("The Value of A=%d B=%d",a,b);
printf("\nAddress of A and B %d %d",&a,&b);
}
void swap(int *x,int *y)
{
printf("\n\n\nBefore\n");
printf("Inside Swaping Function\n");
printf("\nAddress of Denoting X and Y %d %d",x,y);
printf("\nAddress of pointer %d %d",&x,&y);
printf("\n The value of X and Y %d %d",*x,*y);
printf("\n\n\n");
int temp=*x;
*x=*y;
*y=temp;
printf("\nAfter\n");
printf("\nAddress of Denoting X and Y %d %d",x,y);
printf("\nAddress of pointer %d %d",&x,&y);
printf("\n The value of X and Y %d %d",*x,*y);
printf("\n\n\n");
}