Write a function that takes an integer as a parameter and adds the alternate digits in the integer.

Posted by Bhanu6545 under C# category on | Points: 40 | Views : 630
- Do not use arrays/strings use only integers
- Use a single loop
For eg: given an integer 158176
your program should add 1,8,7 which are in the position 0,2,4 of the integer AND 5,1,6 which are in position 1,3,5 of the integer. So the answer will be 1+8+7=16 and 5+1+6=12
The output will be 16,12

Comments or Responses

Posted by: Satyapriyanayak on: 3/21/2014 Level:Silver | Status: [Member] [MVP] | Points: 10

Login to post response