# C program to find sum of even digits and sum of odd digits in integer

## Program to find the Sum of Odd digits and the sum of even digits present in the given Integer :

Even number can be divided by 2. The remainder after dividing an even number by 2 is zero. Odd number can not be divided by 2. The remainder after dividing an Odd number by 2 is one. For example . . . Sum of Even digits of number 6547 is 10 and Sum of Odd digits of number 6547 is 12. The below given C program is used to find the Sum of odd digits and Sum of even digits present in the given Integer number using if statement. Kindly check out to find the Sum of odd digits and Sum of even digits present in the given Integer number.

### Sum of even digits and Sum of odd digits program

#include<stdio.h>

int main(){

int num,rem,odd=0,even=0,digit,input;

printf("  Enter an integer number: ");

scanf("%d",&num);

input = num;

num = abs(num);

while(num>0){

digit = num % 10;

num = num / 10;

rem = digit % 2;

if(rem != 0)

odd=odd+digit;

else

even=even+digit;

}

printf("\n  The sum of Odd digits present in %d is %d.",input,odd);

printf("\n  The sum of even digits present in %d is %d.",input,even);

getch();

return 0;

}

### Sample outputs:

Enter an integer number: 2563

The sum of Odd digits present in 2563 is 8

The sum of even  digits present in 2563 is 8

Enter an integer number: 7568

The sum of Odd digits present in 7568 is 12

The sum of even  digits present in 7568 is 14

• Pdf
• Antiviruses
• Armstrong