# Thread: Simple help. Breaking up "abc"

1. ## Simple help. Breaking up "abc"

Well its been the whole summer since I have programmed and I'm a little rusty. Also, my CS teacher from last semester did not teach me this, and my CS teacher this semester already expects me to know it.

I simply need the equation to get 'b' out of 'abc'

Code:
```#include <iostream>

using namespace std;

int main()
{
int abc, a, b, c;

cout << "Cameron Burton - CS 1362 - Lab 2" << endl;

for(abc=100;abc<=999;abc++)
{
a=abc/100;
b=?????;
c=abc%10;

if(a+b+c == abc)
{
cout << abc << endl;
}
}
return 0;
}```

2. Well if you know that division takes the digits off the front and modulus takes the digits off the back...

Have you ever peeled a fruit?

Oh and addition of integers isn't concatenation of integers, there for (9+9+9 != 999). Got it?

3. Well I have tried this...
Code:
```for(abc=100;abc<=999;abc++)
{
a=abc/100;
ab=abc/10;
b=ab%10;
c=abc%10;

if(a+b+c == abc)
{
cout << abc << endl;
}
}```
but it still yields no results. and just by doing math in my head, I know that 1+2+3 is equal to 1*2*3. So there has to be some output.

EDIT: Ok i saw your edit. Thats how my CS teacher wrote it on the board. So I don't know if he's lost his mind or what, but I know 9+9+9 != 999 What I'm trying to do is find all numbers that a+b+c == a*b*c
But to do that I need to single out 'b' like I have already done with 'a' and 'c'.

4. Yeah, but that's not what you're comparing. You're comparing a+b+c to abc -- that is, you'd be comparing 1+2+3 (6) to 123, and 6 != 123.

It will never print anything, because abc = 100a + 10b + c.

100a + 10b + c = a + b + c is the same as 99a + 9b = 0.

Because a is a positive number, and b cannot be negative, that equation has no solution.

If you want to compare a + b + c and a * b * c you'd need to actually code that.

5. Ok. Thanks Cat and Sly, thanks alot. My teacher wrote it on the board as a+b+c == abc. I guess he assumed we would know to change 'abc' to 'a*b*c'.

When it comes to programming with me, it's always something easy I miss. I'll write the hardest part of the code and always miss something. lol

Thanks again.

6. Also, my CS teacher from last semester did not teach me this...
Don't expect them to "teach" you everything! There's a lot to C++ and they can't cover everything. Well... I guess you could cover most of the C++ standard in two college-level semester classes.

Well its been the whole summer since I have programmed and I'm a little rusty.
Yeah, even if they could teach you everything, you're not going to remember it all. Professional programmers always keep their reference books (and their online references) handy.

IMHO taking a class is the best way to learn*, but you need to supplement that with books (at some point, probably some reference books in addition to your textbook), online references, online tutorials, and this-here forum!

* I think most people here are learning on their own. But, most of the people with the "good answers" have taken programming classes. Many of these people are professional programmers with CS degrees. (I've never taken a C++ class, but I've taken classes in other programming languages.)

7. Code:
`b=abc/10-a*10;`

8. I don't understand what you mean. Do you want to receive an input string (char array)?