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
Does dev c++ support c++ 11?
Do the parentheses after the type name make a difference with new?
What is late binding c++?
What is ostream in c++?
Is it possible for a member function to use delete this?
What is the size of a vector?
What is void pointer in c++ with example?
Define what is constructor?
Differentiate between a copy constructor and an overloaded assignment operator.
Do you know about latest advancements in C++ ?
What is private public protected in c++?
What are namespaces in c++?
Do the names of parameters have to agree in the prototype, definition, and call to the function?
What is a multimap c++?
What are the benefits of c++?