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

A puzzle using a C program

PHPz
PHPzforward
2023-09-19 10:25:021128browse

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));
}

Output

9648

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!

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