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 }