Grokking Java Basics
0% completed
Sum of Digits at Even and Odd Places
Problem Statement
Write a Java program to calculate the sum of digits located at even positions and the sum of digits located at odd positions in a given number. Positions are counted from the right (least significant digit) starting at position 1. For example, in the number 12345, the digits at odd positions are 5, 3, and 1, and the digits at even positions are 4 and 2.
Examples
Example 1:
- Input:
number = 12345 - Output:
Sum of digits at odd positions: 9 Sum of digits at even positions: 6 - Justification:
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%