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 2 chars without using a third
varable?
char *s = "A";
char *p = "B";

Answer Posted / koushik sarkar

#include<stdio.h>
void swap(char *p,char *s){*p=*p+*s-(*s=*p);}
int main()
{
char a,b;
a='A';b='B';
printf("a=%c,b=%c",a,b);
swap(&a,&b);
printf("a=%c,b=%c",a,b);
return 0;
}

Is This Answer Correct ?    4 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does dev c++ support c++ 11?

963


Do the parentheses after the type name make a difference with new?

1035


What is late binding c++?

926


What is ostream in c++?

959


Is it possible for a member function to use delete this?

1022


What is the size of a vector?

1060


What is void pointer in c++ with example?

1023


Define what is constructor?

1003


Differentiate between a copy constructor and an overloaded assignment operator.

1018


Do you know about latest advancements in C++ ?

1158


What is private public protected in c++?

982


What are namespaces in c++?

1031


Do the names of parameters have to agree in the prototype, definition, and call to the function?

978


What is a multimap c++?

1140


What are the benefits of c++?

981