Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program to swap Two numbers without using temp variable.

Answer Posted / ankit

#include<stdio.h>
void swap(int *,int *);
void main()
{
int a,b;
clrscr();
printf("enter two numbers");
scanf("%d%d",&a,&b);
swap(&a,&b);
/* b=(a+b)-(a=b); 1st method */
/* 2nd method
a=a+b;
b=a-b;
a=a-b; */
/* 3rd Method
a=a*b;
b=b/a;
a=a/b; */
/*4th Method
a=a^b;
b=b^a;
a=a^b; */
/* 5th Method
using pointer*/
printf("a=%d\nb=%d",a,b);
getch();
}
void swap(int *a,int *b)
{
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you restore a redirected standard stream?

1052


Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?

1441


c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above

1203


How can you increase the allowable number of simultaneously open files?

1089


What is the difference between a string and an array?

1152


Explain what will be the outcome of the following conditional statement if the value of variable s is 10?

1185


What is quick sort in c?

1016


What are the types of data structures in c?

1081


How can I delete a file?

1014


How do c compilers work?

1049


How do you print an address?

1207


Why is struct padding needed?

1026


What is a pointer on a pointer in c programming language?

1091


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1949


Write a code to determine the total number of stops an elevator would take to serve N number of people.

1187