Posts

Showing posts with the label Call by reference

Pointer Program #3

Image
12. Swap two numbers using user defined function. (Use concept of Call by Reference).  #include<stdio.h> void swap(int *,int *); void main() {      int x,y;      printf("Enter the values of first number:\n");      scanf("%d",&x);      printf("Enter the values of second number:\n");      scanf("%d",&y);      swap(&x,&y);      printf("\nValues inside the main function:");      printf("\nfirst=%d,second=%d\n",x,y); } void swap(int *a,int *b) {      int t;      t=*a;      *a=*b;      *b=t;      printf("\nValues inside the swap function:");      printf("\nfirst=%d,second=%d",*a,*b); } Output Enter the values of first number: 3 Enter the values of second numbe...