bsc

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

root / semester_1 / tuition-c / P033.c

P033.c (504B)


      1 /* WAP to calculate the sum of even digits and odd digits. Number will be provided by user. */
      2 
      3 #include <stdio.h>
      4 int main()
      5 {
      6     int inp, odd = 0, even = 0, temp;
      7     printf("Enter the number : ");
      8     scanf("%d", &inp);
      9     temp = inp;
     10     while (temp > 0)
     11     {
     12         if ((temp % 10) % 2 == 0)
     13             even += temp % 10;
     14         else
     15             odd += temp % 10;
     16         temp /= 10;
     17     }
     18     printf("\nSum of even : %d"
     19            "\nSum of odd : %d",
     20            even, odd);
     21     return 0;
     22 }
© 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