Pages

Thursday, 8 January 2015

C Program To Swap Two Numbers Without Using Third Variable(Using Multiplication)

/* Swapping of two numbers without using third variable in c(using multiplication) */

For any query regarding c/c++ feel free to contact me on khimanichirag@gmail.com or comment below. I try my best to solve it.

 #include<stdio.h>  
 #include<conio.h>  
 void main()  
 {  
   int first_number, second_number;  
   clrscr();  
   printf("Enter the first number: ");  
   scanf("%d",&first_number);  
   printf("Enter the second number: ");  
   scanf("%d",&second_number);  
   first_number=first_number*second_number;  
   second_number=first_number/second_number;  
   first_number=first_number/second_number;  
   printf("After swapping first number is: %d and \nsecond number is: %d",first_number,second_number);  
   getch();  
 }  

No comments:

Post a Comment