A C Puzzle in C Programming?


In this C programming puzzle you need to merge two numbers. You cannot use any arithmetic, string or other functions.

So In This C Puzzle −

Input : 12 , 54
Output : 1254

Optimum solution to this C programming puzzle is to use the Token-pasting operator define.

Define a macros using this ## token-pasting operator gives you the merged value. This operator merges the tokens that are passed to it.

PROGRAM TO SOLVE THE C PUZZLE

#include <stdio.h>
#define merge(a, b) b##a
int main(void) {
   printf("%d ", merge(432 ,23));
   return 0;
}

Output

23432

Updated on: 08-Aug-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements