Digits of a Number

Lab C Beginner 10 points

Read a three-digit number and print its digits separated by spaces, then their sum.

Input

One integer 100–999.

Output

Two lines.

Example

Input

472

Output

4 7 2
13
Sample input available Sample output available
Editor
C

Hints

n % 10 is the last digit; n / 10 removes it.

Solution explanation

Dividing by powers of ten shifts the digits right.

Show solution
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int a = n / 100, b = n / 10 % 10, c = n % 10;
    printf("%d %d %d\n", a, b, c);
    printf("%d\n", a + b + c);
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD