How to swap two ASCII numbers?



How to swap two ASCII numbers?..

Answer / Sudipa Acharjee

To swap the values of two variables containing ASCII characters, you can use a temporary variable in C++ as follows:

```cpp
char a = 'A';
char b = 'B';

// Swap a and b
char temp = a;
a = b;
b = temp;
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ Code Interview Questions

how to write a program that opens a file and display in reverse order?

1 Answers   SMC,


1+1/2!+1/3!+...+1/n!

1 Answers  


write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation

1 Answers   HCL,


write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n

1 Answers   Jomo Kenyatta University,


what is the difference between int &r and int& r

3 Answers  


write a proram using exceptional handling create a error & display the message "THERE IS AN ERROR?... PLEASE RECTIFY"?

1 Answers  


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

1 Answers  


How reader and writer problem was implemented and come up with effective solution for reader and writer problem in case we have n readers and 1 writer.

6 Answers   Microsoft, NetApp,


Coin Problem You are given 9 gold coins that look identical. One is counterfeit and weighs a bit greater than the others, but the difference is very small that only a balance scale can tell it from the real one. You have a balance scale that costs 25 USD per weighing. Give an algorithm that finds the counterfeit coin with as little weighting as possible. Of primary importance is that your algorithm is correct; of secondary importance is that your algorithm truly uses the minimum number of weightings possible. HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!!

1 Answers   Motorola, Qatar University,


Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?

2 Answers   ABC, Qatar University,


write a program using virtual function to find the transposing of a square matrix?

1 Answers  


using repetition structure. Write a c program that will accept five numbers. The program should count and output the total count of even numbers and total count of add numbers.

2 Answers  


Categories