PLEASE HELP-INTERVIEW QUESTION

Hello! I got a really interesting question at a company, and I can't seem to find an answer at all. It really bothers me, please help me.

1
2
3
4
5
6
7
8
9
10
11
12
  #include <cstdio>
int main()
{
    int num = 123456789;
    int res = 0;
    for (int i = 0; i<111111111; i++)
    {
    res=(res+num)%1000000000;
    }
    printf("06 %09d", res);
    return 0;
    }


I should declare num so the output is my mobile number, 305089171.
Any idea how to do that?
I doubt this could be as simple as
int num = 305089171;

You wouldn't post such a simple question here, would you?
There's probably another problem, so let's hear it.
Last edited on
It should be something simple,
they said to "What should "num" be so the output is your mobile number?"
Or something like that.
Oh, I see. The output has to be your mobile number.
Okay, that one is a little difficult, let me think about it.
Thank you in advance :)
Answer is 254197461, dont know why yet, though
Since they named it num, I think they want you to say num should be a signed long long. It could be a string, but could not be a int, and you probably wouldn't want it to be a double since that would have decimals.

The best answer would probably be "a 8bit variable or string".

Edit. That assumes your in the US and your ph# is 9 digits, if you have a 8 digit number you could use int.
Last edited on
Topic archived. No new replies allowed.