Home  >  Article  >  Backend Development  >  A C puzzle in C programming?

A C puzzle in C programming?

WBOY
WBOYforward
2023-09-01 19:09:07561browse

A C puzzle in C programming?

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

So in this C puzzle -

Input : 12 , 54
Output : 1254

The best solution to this C programming puzzle is to use Token-pasting operator define.

Use the ## token-pasting operator to define a macro to get the merged value. This operator merges together the tokens passed to it.

Program to solve C puzzle

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

Output

23432

The above is the detailed content of A C puzzle in C programming?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete