By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,848 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

I need Help

P: n/a
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.

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
k_***@hotmail.com wrote:
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.
Jul 23 '05 #2

P: n/a
k_***@hotmail.com wrote:
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-lit...t.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

--
Chris M Soanes: Amateur Sailor, Windsurfer, Cyclist, Biker, Mechanic,
Welder, Snowboarder, Swimmer, Dog Owner, Real Ale Drinker; Professional
Geek.
Its not a saviour that we want, just somebody else to crucify! - NMA

Jul 23 '05 #3

P: n/a
Chris Soanes wrote:
*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.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.