bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / practice-c / pc009.c

pc009.c (408B)


      1 /* Sum of digit */
      2 
      3 #include <stdio.h>
      4 int main()
      5 {
      6     int num, sumOfDigit = 0, temp;
      7     printf("Enter the number : ");
      8     if (scanf("%d", &num) != 1)
      9     {
     10         printf("\nOnly a number is allowed.");
     11         return 1;
     12     }
     13     temp = num;
     14     while (temp > 0)
     15     {
     16         sumOfDigit += temp % 10;
     17         temp /= 10;
     18     }
     19     printf("\nSum of the digit %d : %d", num, sumOfDigit);
     20     return 0;
     21 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror