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
Write about the stack unwinding?
What is doubly linked list in c++?
What is class syntax c++?
Define what is constructor?
Which programming language should I learn first?
Is it possible to get the source code back from binary file?
What is setfill c++?
What is the use of dot in c++?
Difference between overloading vs. Overriding
Can we make any program in c++ without using any header file and what is the shortest program in c++.
What is an operator in c++?
How do you show the declaration of a virtual constructor?
What is a virtual destructor? Explain the use of it?
What is a down cast?
What type of question are asked in GE code writing test based on c++ data structures and pointers?