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
What is a constructor and how is it called?
Do you know about latest advancements in C++ ?
What are c++ stream classes?
What are the effects after calling the delete this operator ?
What is the use of vtable?
How do I use turbo c++?
How do c++ struct differs from the c++ class?
What do you mean by function pointer?
What is helper in c++?
How a macro differs from a template?
Explain some examples of operator overloading?
Can member data be public?
What are static and dynamic type checking?
What are put and get pointers?
Evaulate: 22%5 a) 2 b) 4 c) 0