Give a = 12 and b = 36 write a C function/macro that returns 3612 without using arithmetic, strings and predefined functions.
We strongly recommend you to minimize your browser and try this yourself first.
Below is one solution that uses String Token-Pasting Operator (##) of C macros. For example, the expression “a##b” prints concatenation of ‘a’ and ‘b’.
Below is a working C code.
#include <stdio.h> #define merge(a, b) b##a int main(void) { printf("%d ", merge(12, 36)); return 0; } |
chevron_right
filter_none
Output:
3612
Thanks to an anonymous user to suggest this solution.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Difference Between C Language and LISP Language
- C Programming Language Standard
- Benefits of C language over other programming languages
- Introduction to the C99 Programming Language : Part I
- Introduction to the C99 Programming Language : Part II
- Introduction to the C99 Programming Language : Part III
- Features of C Programming Language
- Programming puzzle (Assign value without any control statement)
- C Language Introduction
- Arrays in C Language | Set 2 (Properties)
- Convert C/C++ code to assembly language
- Signals in C language
- Constants vs Variables in C language
- Difference between %d and %i format specifier in C language
- lvalue and rvalue in C language
- kbhit in C language
- How to use POSIX semaphores in C language
- fgets() and gets() in C language
- isxdigit() function in C Language
- isupper() function in C Language

