Hello,
I posted this and saw it on the board, but it disappeared so I'm going to try again. My apologies if someone has it down to try and help me. I am trying to write a program for homework. For the first part of the program I have to take 4 digit numbers, add the first 2 and last 2 digits, square them and compare to the original number. I'm fine on that and the first part of the program works. I'm very new to C++, and appreciate any help ( In the 5th week of beginers C++ class)
For the second half I have to take 2,3,and 4 digit numbers, cube their digits, add them back to the original number and compare. I copied the for loop that worked previously, changed what I needed to, ran a test, and it didn't work. I took the cubing for loop out and ran it separately and verified the argument worked without the for loop by making it cout the separate digits and the sum of the cubes. I did it only with 3 digit numbers because I know there are 4 of them that fulfill the requirements. Could someone please check my program and help me to understand what I'm doing wrong that the 2nd for loop won't work by itself, or with the first for loop, which works fine.
Thanks
First off, you've got a bunch of stuff that I don't think needs to be there. Shoot me and e-mail and I'll see if I can't help ya out. I'll need to ask you some more rather in-depth questions, and rather than clog the board, e-mailing would be much more efficient for this.
But then nobody is learning something out of it. And that is one reason for having
a forum.
Your question:
I think you calculate with floats in part 2. You declared int. Or am I wrong?
Hello,
Just to let everyone know. I also emailed my class prof to ask for help (He's not the amrcn.uga.edu person). The prof of my class emailed me back to use a temp variable instead of num for digitizing. This is because in the calculations change num every time it gets divided. For example temp=num; before the dig3 = statement, and then replace all of the nums with temp so that at the end you can compare the scube (sum of the cubes) with the original number (num). I did it and it worked for me.