Home > Backend Development > C++ > A puzzle using a C program

A puzzle using a C program

PHPz
Release: 2023-09-19 10:25:02
forward
1171 people have browsed it

A puzzle using a C program

Here we will see a C puzzle. Suppose we have two numbers 48 and 96. We have to add the first number after the second number. So the final result will be 9648. But we cannot use any logical, arithmetic, string-related operations, nor can we use any predefined functions. So how can we do this?

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

Example

#include<stdio.h>
#define MERGE(x, y) y##x
main() {
   printf("%d", MERGE(48, 96));
}
Copy after login

Output

9648
Copy after login

The above is the detailed content of A puzzle using a C program. 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