### missing number

I'm trying to create this program but i have some problems if some one can help
i need to find mission phone number,so it should work on this system

1- enter the first three numbers of the phone
2- multiply by 80
3- add 1 to that total
4- multyply by 250
6- subtract 250 from total
7- divide by 2

I write this program but it's not working correct since missing number is not showin

example my phone number is :37745579

in program i need to put first 3 numbers
and then next four last numbers
then program after mathematicaly calculate everything suppose to find a missing number 4

here is my code

#include <iostream>
using namespace std;

int getNumberFromUser(int n)
{
int num;

cout << "\nEnter the first " << n << " digits of your phone number: ";
cin >> num;

return num;
}

int calculation1(int num)
{

num = num * 80;

num = num + 1;

num = num * 250;

return num;
}

int calculation2(int num, int num1)
{

num = num + num1;

num = num + num1;

num = num - 250;
num = num / 2;

return num;
}
int main()
{
int num, num1;
char ch;

cout << "\t\t\t******* Number *******\n";

num = getNumberFromUser(3);

num = calculation1(num);

num1 = getNumberFromUser(4);

num = calculation2(num, num1);

//show the result
cout << "\nResult: " << num;
cout << "\n\n\n";
cout << "Enter 0 for exit: ";
cin >> ch;
system ("pause ");
return 0;
}
say, you have a phone number as AXB, while A is the first 3 digits, X is the missing one, B is the last 4 digits.
1- enter the first three numbers of the phone
2- multiply by 80
3- add 1 to that total
4- multyply by 250
6- subtract 250 from total
7- divide by 2

(((A * 80 + 1) * 250 + B * 2) - 250) / 2
= A * 80 * 250 / 2 + B
= A * 10000 + B
so nothing related to X
You need some kind of rule that all phone numbers follow in order to get the missing digit. For example 'all phone numbers total 47' or 'all phone number are divisible by 11'.

At the moment (as briefly explained above), all you're getting is:

2) Multiply by 80 - We will do this together with 4) Multiply by 250. These two steps together are equivalent to doing n * (80 * 250) or n * 20000.

3) +1 - Since this is getting multiplied by 250, you're just adding 250 to the number.
6) Subtract 250 from your number - This simply undoes step 3. So step 3 and 6 can be ignored, as they have no overall effect.

5) Lets call the last 4 digits 'p' and so we add 2p.

7) Divide by 2 and we are left with (20000n + 2p) / 2 or simplified: 10000n + p.
Topic archived. No new replies allowed.