ads

Sunday, 28 August 2016

c program to find sum of digits in the number

#include<stdio.h>
#include<conio.h>
void main()
{
  int a,sum=0,q,n;
  printf("enter the numbers:");
  scanf("%d",&a);
  while(a!=0)
 {
   q=a%10;
   sum=sum+q;
   a=a/10;
 }
 printf("sum of digits:%d",sum);
 getch();
}

No comments:

Post a Comment