Menu
Coddy logo textTech

Even / Odd Sum

Lesson 3 of 25 in Coddy's Coding Problems: Volume 2 course.

Create a program that calculates the sum of digits on even positions, and on odd positions of a given number

challenge icon

Challenge

Easy

Write a program that reads a 5-digit number and outputs the sum of the digits on the even positions, and the sum of the digits on the odd positions
The first digit is in position 0, second in 1, so the first digit is in an even position

Input
54321

Output
Sum of even: 9
Sum of odd: 6

Try it yourself

#include <stdio.h>

int main() {
    // Write code here
    return 0;
}

All lessons in Coding Problems: Volume 2