1num = [int(d) for d in input("Enter the Number:")]
2sum = 0
3for i in range(0, len(num)):
4 sum = sum + num[i]
5
6print("Sum of Digits of a Number: {}".format(sum))
7
8# This code is contributed by Shubhanshu Arya (Prepinsta Placement Cell Student)
1#include <stdio.h>
2
3int getSum(unsigned long long n) {
4 int sum = 0;
5 for (; n; n /= 10)
6 sum += n % 10;
7 return sum;
8}
9
10int main(){
11 printf("Sum of digits = %d\n", getSum(555));
12}