4. Sum the digit of a given number.


        #include <stdio.h>
        #include <conio.h>
    
        void main()
        {
            int num, rem, sum = 0, temp;
            clrscr();
            printf("Enter the number:");
            scanf("%d", &num);
            temp = num;
            while (num != 0)
            {
                rem = num % 10;
                sum += rem;
                num = num / 10;
            }
            printf("The sum of %d decimal digits is %d", temp, sum);
        }
        

Output

    Enter the number:123
    The sum of 123 decimal digits is 6