program in c++

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2008
Posts: 4
Reputation: rathmal is an unknown quantity at this point 
Solved Threads: 0
rathmal rathmal is offline Offline
Newbie Poster

program in c++

 
0
  #1
Feb 16th, 2008
please help me to write a program in c++ to find sum of first and last digits of any number
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 462
Reputation: Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough Agni is a jewel in the rough 
Solved Threads: 71
Sponsor
Agni's Avatar
Agni Agni is offline Offline
Posting Pro in Training

Re: program in c++

 
0
  #2
Feb 16th, 2008
have you written some code?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 98
Reputation: codeaa is an unknown quantity at this point 
Solved Threads: 12
codeaa codeaa is offline Offline
Junior Poster in Training

Re: program in c++

 
0
  #3
Feb 16th, 2008
Break the problem down into small tasks.

First, you need to find a way to get the first digit and the last digit.

There are many different ways you could get these digits.

One way might be to convert the number into a string. Once you have the string, there are several ways you can get the first and last character.

Convert those characters representing the first and last digit to an int.

Once you have those digits, simply add them together.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: program in c++

 
0
  #4
Feb 16th, 2008
Originally Posted by rathmal View Post
please help me to write a program in c++ to find sum of first and last digits of any number
/ and % can come handy.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 600 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC