Monday, March 26, 2012

Program to find sum of digits of given number in C code


/*****************<soeasyprograms.blogspot.in>******************/
#include<stdio.h>
#include<conio.h>
void main()
{
   int n,a,b=0;
   clrscr();
   printf("Enter the value of n");
   scanf("%d",&n);
   while(n>0)
   {
    a=n%10;
    b=a+b;
    n=n/10;
    }
    printf("The sum of digits of given number is %d",b);
    getch();
}


/*****************<soeasyprograms.blogspot.in>******************/

No comments:

Post a Comment