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

What flag means?

1014


What is scope in c++ with example?

1192


Is c++ a high level language?

1053


If you don’t declare a return value, what type of return value is assumed?

1007


Why namespace is used in c++?

1118


Why is c++ considered difficult?

1224


What is a block in c++?

1101


What's the "software peter principle”?

1199


What is a dangling pointer in c++?

1205


What is main function in c++ with example?

1304


How would you implement a substr() function that extracts a sub string from a given string?

1107


Give the difference between the type casting and automatic type conversion. Also tell a suitable C++ code to illustrate both.

1107


What is the benefit of encapsulation?

1124


Who made c++?

1134


Define what is constructor?

1117