Now that we’ve covered most of the basics, we will be learning to solve different problems. In this lesson, we will think of a solution together to write a program that takes a number and calculates the sum of its digits.

So let’s get to it!

Sum of digits

Write and run a digits summation program (using operators +, %, /) that takes a six-digit integer from the user and prints the sum of its six digits.

Sample Input:


Sample output:


Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy