Open In App
Related Articles

A C Programming Language Puzzle

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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;
}

                    
Output:
3612
Thanks to an anonymous user to suggest this solution.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!


Last Updated : 21 Jun, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads