A Puzzle using C Program

CServer Side ProgrammingProgramming

Here we will see one C puzzle question. Suppose we have two numbers 48 and 96. We have to add the first number after the second one. So final result will be like 9648. But we cannot use any logical, arithmetic, string related operations, also cannot use any pre-defined functions. So how can we do that?

This is easy. We can do by using Token Pasting operator(##) in C. The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro definition.


#define MERGE(x, y) y##x
main() {
   printf("%d", MERGE(48, 96));


Published on 20-Aug-2019 10:27:35