Given a number the task is to find the sum of even digits present in the number.
Example 1: Let us take a numberĀ 3412. Here sum of even digits is 4+2=6.
C
#include <stdio.h>
int main()
{
int n=0,r=0,sum=0;
printf("Enter a number: ");
scanf("%d",&n);
while(n>0)
{
r=n%10;
if(r%2==0)
{
sum=sum+r;
}
n=n/10;
}
printf("Sum of even digits: %d",sum);
return 0;
}C