C Program to Swap Two Numbers using Pointer

C Program to Swap Two Numbers using Pointer:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().


void swap(int *num1,int *num2)
   int temp;
   temp = *num1;
   *num1 = *num2;
   *num2 = temp;

   int num1,num2;

   printf("Enter the first number : ");
   printf("\nEnter the Second number : ");


   printf("\nFirst number is : %d", num1);
   printf("\nSecond number is : %d", num2);


Enter the first number : 5

Enter the Second number : 8

First number is : 8
Second number is : 5

Leave a Reply

Your email address will not be published. Required fields are marked *