Embercode
✕
C++ OperatorsCoding problems

C++ Operators: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 7 solved

  • A warehouse labels each bin with a three-digit number such as 472. The clerk needs a check digit for each bin, and it is the sum of the three digits of the bin number. Read one three-digit number and print the sum of its digits.

    Use / and % to take the digits apart. Do not read the number as text.

    **Constraints:** the number is from 100 to 999.

    Input. One integer n, from 100 to 999.

    Output. One integer: the sum of the three digits of n.

    Example 1 input

    472
    

    Output

    13
    

    Example 2 input

    908
    

    Output

    17