Exchange values using call by value

Program:

#include<stdio.h>
void exch(int a,int b)
{
  int temp;
  temp=a;
  a=b;
  b=temp;
  printf("Inside Function::\n");
  printf("a=%d b=%d\n",a,b);
}
int main()
{
int x,y;
printf("Enter value of x and y: \n");
scanf("%d%d",&x,&y);
exch(x,y);
     printf("From main Function::\n");
     printf("x=%d y=%d\n",x,y);
     return 0;
}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...