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

A C puzzle in C programming?

WBOY
Release: 2023-09-01 19:09:07
forward
770 people have browsed it

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
Copy after login

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;
}
Copy after login

Output

23432
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template