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

Bhanu6545
Posted by Bhanu6545 under C# category on | Points: 40 | Views : 1221
Write a function that takes an integer as a parameter and adds the alternate digits in the integer.
- 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

Login to post response