Posts

Showing posts with the label Call by value

Pointer Program #2

Image
11. Swap two numbers using user defined function. (Use concept of Call by value). #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 number: 5 Values inside the swap functio...