Absolute Difference?

Hi again; as you guys can probably guess, my teacher is not very nice. He likes saying things like "I'll leave you to figure it out" without going over something important in lecture.

Anyways, this time, I'm not looking for a solution just some general guidance because I really want to understand the how and why of this one. I've been tasked with writing a program that reads and echoes integers until the difference between two successive integers is greater than, or equal to, 10 while utilizing the function abs() to find the absolute value of the difference.

I understand that I'll need to create a function, I'm actually pretty good at that part. What's going over my head is how to make sure that said function is called with every new integer entered by the user until the difference is >= 10.

Any assistance would be greatly appreciated, especially explanation.
Thanks in advance,
X
ok lets say you have two integers
int i, j;
now if the difference it 10 or greater it ends so we need a difference integer
int difference;
so lets see the thought process
1
2
3
4
5
6
7
 
int i, j, difference; 
while(true){
//get number
//difference = your function
//something to break loop
}

Thank you for your help so far, it's be great. I've got it pretty much, except that even after entering a pair of numbers I KNOW has a difference of more than 10, it requires me to enter one more pair before it will display that said difference is more than 10.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int main ()
{
	int num1, num2, difference = 0;


	cout << "Please enter some numbers. " << endl;
	cin >> num1;
	cin >> num2;

	while (difference <= 10)
	{
		difference = diff (num1, num2);
		cin >> num1;
		cin >> num2;
	}

	cout << difference << " is greater than 10!" << endl;
	cout << endl;

	cout << "END OF LINE." << endl;
	return 0;


What should I consider trying?
Nevermind! I screwed around with it a bit and I got it! Thank you so much again for all your help!
Topic archived. No new replies allowed.