Skip to content

p033.c

Problem Statement

WAP to calculate the sum of even digits and odd digits. Number will be provided by user.

Metadata

Property Detail
Author Amit Dutta (amitdutta4255@gmail.com)
License MIT

Actions

Raw View on GitHub

💡 You can print or save this file by opening Raw and using your browser.

Source Code

#include <stdio.h>
int main()
{
    int inp, odd = 0, even = 0, temp;
    printf("Enter the number : ");
    scanf("%d", &inp);
    temp = inp;
    while (temp > 0)
    {
        if ((temp % 10) % 2 == 0)
            even += temp % 10;
        else
            odd += temp % 10;
        temp /= 10;
    }
    printf("\nSum of even : %d"
           "\nSum of odd : %d",
           even, odd);
    return 0;
}