Saturday, 30 December 2017

C program to find sum of digits of given number

#include<stdio.h>
int main( )
{
    int n, i, sum=0;
    
    printf("Enter the number");
    scanf("%d",&n);

   while(n>0)

   {
         i=n%10;
         n=n/10;
         sum=sum+i;
   }
   
 printf("sum is %d",sum);

return 0;

}





No comments:

Post a Comment

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...