Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

digit sum number in c

#include <stdio.h>

int main() {
    int number;
    int sum=0,reminder;
    printf("enter the number:");
    scanf("%d",&number);
    while (number>0){
        rem=number%10;
        sum=sum+rem;
        number = number/10;
    }
    printf("%d",sum);
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #digit #sum #number
ADD COMMENT
Topic
Name
8+4 =