C Program To Find Sum Of Individual Digits


#include<stdio.h>
int main()
{     int a, sum;
    printf("Enter the digits: ");
    scanf("%d",&a);
    for(sum=0;a>0;a=a/10)
        sum = sum + (a%10);
    printf("Sum of digits: %d",sum);
    return 0; 
}

Output:-
C program to find sum of individual digits

Share To:

Arogya Thapa Magar

Post A Comment:

0 comments so far,add yours