QUESTION- SWAPPING TWO NO. USING POINTER AFTER PASSING THEM TO FN.
ANSWER-
#include<conio.h>
#include<stdio.h>
int swap(int *a,int *b);
int main()
{
int num1,num2; // address of num1 and num2 is passed to swap function
printf(“\nInput Number1 : “);
scanf(“%d”,&num1);
printf(“\nInput Number2 : “);
scanf(“%d”,&num2);
swap(&num1,&num2);
printf(“\nNO. AFTER SWAPPING:”);
printf(“\n\nNUMBER1= %d \t NUMBER2= %d”,num1,num2);
printf(“\n\n\tPROGRAMMING @ CODE STUDIO”);
getch();
}
int swap(int *a,int *b)
{ // pointer a and b points to address of num1 and num2 respectively
int temp;
temp=*a;
*a=*b;
*b=temp;
}
OUTPUT-