[ create a new paste ] login | about

Link: http://codepad.org/34rJpmkB    [ raw code | fork ]

C, pasted on Oct 10:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
int main() {
  int n, c;
  int sum;
  while (scanf("%d", &n) == 1 && n >= 0) {
    sum = 0;
    for (;;) {
      c = n % 10;
      printf("%d", c);
      sum += c;
      n /= 10;
      if (n <= 0)
        break;
      putchar('+');
    }
    printf("=%d\n", sum);
  }
  return 0;
}
/* end */


Output:
No errors or program output.


Create a new paste based on this one


Comments: