Absolute difference? C++

Okay, I'm confused as to what I need to put in my main function or if I incorrectly used anything in my diff function. I'm trying to stay away from decisions in code (if, else statements), but I don't believe I can't use them.

The requirements are that I "write a program that accepts integer values from the keyboard one at a time until the absolute difference between two successive integers is greater than, or equal to, 10."

I need to use the abs() function as well.

Help me? Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <cmath>

using namespace std;

int diff(int, int);

int main()
{
	int num1, num2;

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

	cout << "The difference is greater than 10." << endl;

	return 0;
}
int diff(int a, int b)
{
	int equal, diff, d = 0;
	equal = (abs(a - b) == 10);
	diff = (abs(a - b) < 10);

	for(d = 0; d >= 10; d++)
	{
		d = abs(a - b);
	}

	return d;
}

...for one you never call your diff function inside your main function.
Topic archived. No new replies allowed.