Return statements working with Strings and int's

So I am trying to write a function when called with break up a 3 digit number into a "ones" places, "tens" places and "hundreds" place. What my issues is or at least what I think it is. Is that I am sorta new to using return statements so I am a little lost to how go about it. I know I have the parameter set with a int, and I need the int to be push and pull in the function, but I also I have to spit our a string representation of the ones digit and the ten etc.
I plan on using a array letter to give me string that co-insides with the number(1 =one, 2 = two...11=eleven). So for now I need to see that onesDig, is what I expect but also tensDig and hundredDig is too.
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
  string breakThreeDigit (int num)
{	
	string digit;
	do
	{
	int onesDig, tensDig, hundredDig;

	onesDig = num % 10;
	tensDig = ((num / 10) % 10);
	hundredDig = num / 100;
           //Should I have a cout...here somewhere and make my function void? just to test it?
	}while(num>=3);
	return digit;
}
int main()
{
	int num=132;
	cout << 132%10<< endl;// these are my own example of what 
	cout << 132/10 << endl;//I want the function to do.
	cout << 13%10 << endl;
	cout << 13/10 << endl;
	cout << "below is the function example of breakNum" << endl;
	cout << breakThreeDigit(num) << endl;
	cout << "code gets here" << endl;
	cout << num << endl;
}
Last edited on
Topic archived. No new replies allowed.