Testing.

Monday, 2 January 2017

C programming language: C program for sum of digits.


#include<stdio.h>
#include<conio.h>
void main()
{
int n,sum=0;
int rem;
printf("\nEnter Number: ");
scanf("%d",&n);
 while(n)
  {
   rem=n%10;
   sum=sum+rem;
   n=n/10;
   }
              printf("Sum of Digits: %d",sum);
      getch();
}



No comments:

Post a Comment