Tommy said:
Lets say you have a read (using cin >> ) a couple of numbers that the
user have entered ie. 1234. And you want to add these numbers together
like this, 1+2+3+4=10 How do you do that?
Thanks,
Tommy
So, you are at this point:
#include <iostream>
int main()
{
int a, b;
std::cin >> a >> b;
return 0;
}
And now you want to add 'a' and 'b'? It's quite simple:
#include <iostream>
int main()
{
int a, b;
std::cin >> a >> b;
a + b; // add a and b
return 0;
}
Of course, the next logical step would be to *do something* with the
result. But you didn't say anything about that, so I don't know what you
want to do.
A few hints:
1) Be specific when you ask a question here. We're not good at guessing
what you actually wanted to ask.
2) This is about the most basic question I've ever seen on this group.
You really should not ask these kinds of questions here, for 3 main reasons:
* You can get an answer much more quickly from your C++ book.
* If you attempt to learn C++ by asking questions here, it will take you
approximately 2593 years (I did the math[1]).
* We can't be bothered to answer hundreds of basic questions that you
could have answered yourself in seconds just by picking up a book. It is
a waste of our time.
-Kevin
[1] I did not actually do any math.