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 the difference between overloading & overriding? give example.
Explain the concept of copy constructor?
What is purpose of abstract class?
Why is c++ not purely object oriented?
What is atoi?
Can we declare a base-class destructor as virtual?
Explain all the C++ concepts using examples.
What is flag in computer?
Why do we use the using declaration?
What is boyce codd normal form in c++?
What is the first name of c++?
what is COPY CONSTRUCTOR and what is it used for?
What is const pointer and const reference?
Which is the best c++ compiler for beginners?
Who invented turbo c++?