bool function

this is my working program:
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
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
using namespace std;

int main()
{
	int temp;
	
	cout <<"Enter the desire temperature: ";
	cin>>temp;

	int lowerTemp=temp;
	int onesDigit=temp%10; //First digit
	int tensDigit=(temp/10)%10;//Second digit
	int hundredsDigit=temp/100;//Third digit

	while ((onesDigit==1)||(onesDigit==4)||(onesDigit==7)||
		(tensDigit==1)||(tensDigit==4)||(tensDigit==7)||
		(hundredsDigit==1)||(hundredsDigit==4)||(hundredsDigit==7))
	{
		lowerTemp--;
		onesDigit=lowerTemp%10;
		tensDigit=(lowerTemp/10)%10;
		hundredsDigit=lowerTemp/100;
	}
	
	int higherTemp=temp;
	onesDigit=higherTemp%10;
	tensDigit=(higherTemp/10)%10;
	hundredsDigit=higherTemp/100;

	while ((onesDigit==1)||(onesDigit==4)||(onesDigit==4)||
		(tensDigit==1)||(tensDigit==4)||(tensDigit==7)||
		(hundredsDigit==1)||(hundredsDigit==4)||(hundredsDigit==7))
	{
		higherTemp++;
		onesDigit=higherTemp%10;
		tensDigit=(higherTemp/10)%10;
		hundredsDigit=higherTemp/100;
	}

	cout<< "The closest higher temperature is :"<<higherTemp<<endl;
	cout<< "The closest lower temperature is :"<<lowerTemp<<endl;

	return 0;
}


i need to add
bool containsDigit(int number, int digit);
to the working program and still get the same output.
how would that work?
That function should look at the digits of number and see if any of them are equal to digit.
what is the exact question. I am not sure what you are asking. Whether you need to know how to include this function and call this function from main?
Topic archived. No new replies allowed.