P034.c (591B)
1 /* Get sum of even position digit and odd position digit */ 2 /* Counting starts from the rightmost digit as position 1 (Odd). */ 3 4 #include <stdio.h> 5 int main() 6 { 7 int inp, temp, index = 1, even = 0, odd = 0; 8 printf("Enter the numebr : "); 9 scanf("%d", &inp); 10 temp = inp; 11 while (temp > 0) 12 { 13 if (index % 2 == 0) 14 even += temp % 10; 15 else 16 odd += temp % 10; 17 temp /= 10; 18 index++; 19 } 20 printf("\nSum of even position digits : %d" 21 "\nSum of odd position digits : %d", 22 even, odd); 23 return 0; 24 }