I need Help

K

k_o_l

Hi all,

I'm new to C++, and I'm trying to add the last two digits of a number.
for example, 1988 , 8+8=16 any idea on how to do that?

thanks.
 
V

Victor Bazarov

I'm new to C++, and I'm trying to add the last two digits of a number.
for example, 1988 , 8+8=16 any idea on how to do that?

Read about operator / (division) and operator % (remainder). We're not
going to do your homework for you.
 
C

Chris Soanes

Hi all,

I'm new to C++, and I'm trying to add the last two digits of a number.
for example, 1988 , 8+8=16 any idea on how to do that?

thanks.

*checks date* nope, not september.

This sounds suspiciously like a homework question. We try not to do
people's homework on here, if we can. However, here's a hint:
Convert the number to a string and exctract the last two characters.
Convert them back to numbers and add them. Don't forget to check the
string first to make sure it's really a number.

Another hint:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2

Please to not take offence at the above post. I can assure you that none
was meant.
Welcome to the group; we all hope you stick around and grow to love C++
as we do.

Tiff
 
I

Ioannis Vranos

Chris said:
*checks date* nope, not september.

This sounds suspiciously like a homework question. We try not to do
people's homework on here, if we can. However, here's a hint:
Convert the number to a string and exctract the last two characters.
Convert them back to numbers and add them. Don't forget to check the
string first to make sure it's really a number.



That works but there is an easier numerical way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,653
Latest member
YvonneJif

Latest Threads

Top