Write a program to swap 2 chars without using a third
varable?
char *s = "A";
char *p = "B";
Answer Posted / prasenjit roy
#include <stdio.h>
//No restrinction of datatype
#define SWAP(x,y) { x = x ^ y; \
y = x ^ y; \
x = x ^ y; \
}
void main()
{
char c = 'c';
char d = 'd';
SWAP(c, d);
}
| Is This Answer Correct ? | 13 Yes | 2 No |
Post New Answer View All Answers
How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?
What is a flag in c++?
what is C++ exceptional handling?
What are associate containers?
What are the implicit member functions of class?
Explain this pointer?
What are the four main data types?
Define basic type of variable used for a different condition in C++?
When does a 'this' pointer get created?
What are the advantages of using const reference arguments in a function?
What are the differences between malloc() and calloc()?
How to implement is-a and has-a class relationships?
What is tellg () in c++?
A prime number is a number which is divisible only by itself and 1. Examples of the first few primes are 2, 3, 5, 7, 11. Consider writing a program which can generate prime numbers for you. Your program should read in and set a maximum prime to generate and a minimum number to start with when looking for primes. This program should be able to perform the following tasks: 1. Read the maximum number from user (keyboard input) to look for primes. The program should not return any primes greater than this number. 2. Read the minimum number from user (keyboard input) to look for primes. The program should not return any primes less than this number. 3. Generate and print out every prime number between the maximum prime and minimum number specified by the user.
What is the most common mistake on c++ and oo projects?