bsc

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

P034.c (727B)


      1 /*
      2  * Author: Amit Dutta (amitdutta4255@gmail.com) | Date: 12 Dec 2025
      3  * Repo: https://github.com/notamitgamer/bsc
      4  * License: MIT
      5  */
      6 
      7 /* Get sum of even position digit and odd position digit */
      8 /* Counting starts from the rightmost digit as position 1 (Odd). */
      9 
     10 #include <stdio.h>
     11 int main()
     12 {
     13     int inp, temp, index = 1, even = 0, odd = 0;
     14     printf("Enter the numebr : ");
     15     scanf("%d", &inp);
     16     temp = inp;
     17     while (temp > 0)
     18     {
     19         if (index % 2 == 0)
     20             even += temp % 10;
     21         else
     22             odd += temp % 10;
     23         temp /= 10;
     24         index++;
     25     }
     26     printf("\nSum of even position digits : %d"
     27            "\nSum of odd position digits : %d",
     28            even, odd);
     29     return 0;
     30 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror