Help with some homework logic

Some help with the logic of this question would be great. I'm rather confused as to what it is asking.

2) Write a function BreakUp() that takes an integer in the range 0-999 as a parameter and returns each of the digits in three integer reference parameters. Next, write a function Build() that takes three integer parameters and returns a value which consists of the number represented by the three digits.
Lastly, write a program illustrating BreakUp() and Build() using this specification: Every number from 0 to 999 is first broken up then rebuilt and the result compared to the original value. An error message should be displayed if the original and rebuilt numbers do not match.
Last edited on
I'm not going to do your homework for you, but if you do it yourself and get stuck I can help you then.
It's not that, I need help with the logic. I can write code just fine, but I'm not too sure what number 2 is asking for. Number 1 is done.
It looks to me like you should have two functions.

void BreakUp ( int original, int & digit1, int & digit2, int & digit3 );
int Build ( int first, int second, int third );

The first function takes apart 'original' and splits its digits among the other parameters.
The second function takes three digits and recombines them into one number, returning that number.

Since the numbers are supposed to be positive, I would use unsigned ints. I'm not sure if they want you to do that though. I think it would probably be okay.
Last edited on
Topic archived. No new replies allowed.