Headlines
Loading...
C Program to find the sum of digits of a number

C Program to find the sum of digits of a number

C Program to find the sum of digits of a number 

# include<stdio .h="">
# include<conio .h="">
void main()
{
   int num,sum=0,rem=0;
   clrscr();
   printf("\n Enter a number:");
   scanf("%d",&amp;num);
   while(num&gt;0)
   {
 rem=num%10;
 sum=sum+rem;
 num=num/10;
   }
  printf("\n Sum of digits of a number:%d",sum);
getch();
}

 ***********OUTPUT**************


 Enter a number:56                                                              
                                                                                
 Sum of digits of a number:11</conio></stdio>
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***