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?
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.