Loading...

Finding sum of digits of an integer


/*
* To find the sum of the digits of an Integer
* sshubhamk1.page.tl
*/
#include<stdio.h>
#include<conio.h>
 
void main()
{
    int num, sum=0,i;
    clrscr();
    printf("\nenter the number: ");
    scanf("%d",&num);
    while(num>10)
    {
i = num % 10 ;
sum= sum + i ;
num = num /10 ;
    }
    printf("\nThe sum of the digits of the Integer is %d",sum+num);
    getch();
}
 


123 Sample Rd, Samplington, SA 12345
(555) 0123