-5

I can not use sprintf, or any other function that puts everything together in a string n, I can not really use any libc function, it's part of a challenge I'm trying to solve

Given:

int x=5;
int y=2;

Expected Output:

res = 52;
Krishna
  • 484
  • 7
  • 22
Yuri Albuquerque
  • 474
  • 3
  • 14

1 Answers1

1

This is one posible solution:

#include <stdio.h>

int main()
{
   int x= 342;
   int y= 224;
   int aux = y;
   while( aux ) {
      aux /= 10;
      x*= 10;
   }
   x+= y;
   printf("x= %d\r\n", x);  // prints 342224
}
BlueStrat
  • 2,202
  • 17
  • 27