Skip to main content

Write a program to compute the sum of the digits of a given integer number.


#include<stdio.h>
#include<conio.h>
main()
{
    int num,sum=0,r;
    printf("Enter a number:");
    scanf("%d",&num);
    
    for(num!=0;num=num/10;num++)
    {
        r=num%10;
        sum=sum+r;
        printf("sum of digits of number:%d",sum);
    }
    
    getch();
}