It was asked today in interview but could not crack it, any help.
Its concat i.e. b followed by a. Just need to do some trick
#include <stdio.h> #define myfunc(a,c) b##a int main() { int c; c = myfunc(20,30); printf("%d\n", c); return 0; }
#include <stdio.h> int main(void) { int a, b; scanf("%d%d",&a,&b); printf("%d",b); printf("%d",a); return 0; }
output 3020
I think there is no other way except string concatenation and arithmetic operation for your problem. I would give you simple arithmetic logic
int a=20; int b=30; int c=(b*100)+a;
if you tell your purpose i would give a better solution thank you.
Given input as a string, return an integer as the sum of all numbers found in the string
Input: xyzonexyztwothreeeabrminusseven Output : 1 + 23 + (-7) = 17