fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int num_i,num_ii,temp;
  5. printf("\nTHIS IS A PROGRAM OF SWAPPING 2 NUMBERS USING THIRD VARIABLE\n\n");
  6. printf("--------------------------------------------------------------\n");
  7. printf("Enter the value of first number = ");
  8. scanf("%d",&num_i);
  9. printf("Enter the value of second number = ");
  10. scanf("%d",&num_ii);
  11. printf("--------------------------------------------------------------\n");
  12. printf("\nBefore swapping...\n \nfirst number = %d\nsecond number = %d\n",num_i,num_ii);
  13.  
  14. temp=num_i;
  15. num_i=num_ii;
  16. num_ii=temp;
  17. printf("--------------------------------------------------------------\n");
  18. printf("\nAfter swapping...\n \nfirst number =%d\nsecond number =%d\n",num_i,num_ii);
  19. return 0;
  20. }
  21.  
  22.  
Success #stdin #stdout 0s 2172KB
stdin
Standard input is empty
stdout
THIS IS A PROGRAM OF SWAPPING 2 NUMBERS USING THIRD VARIABLE

--------------------------------------------------------------
Enter the value of first number = Enter the value of second number = --------------------------------------------------------------

Before swapping...
 
first number = -3184292
second number = 1432510029
--------------------------------------------------------------

After swapping...
 
first number =1432510029
second number =-3184292