void main()
{
int
clrscr();
printf("Enter the number");
scanf("%d",&a);
do
{
n=a%10;
flag=(flag*10)+n;
}
while(a==0);
printf("The sum of digits of a number %d is %d",a,flag);
getch();
}

Sorry Thinker but you program doesn't hack it. Its full of syntax errors and undeclared variables, and it just plain doesn't work right. Line 10 does NOT calculate the sum of the digits. If the input number is 15 then the sum of the digits is 1 + 5 = 6. You are on the right track with line 9 but you flunked the course with line 10

The logic is there in your mind. But you have posted something that is very much far from a sound error-free program. Either you were in too much hurry or you need to clear your basics.

#include <stdio.h>
int main()
{
int n = 12345;
int sum = 0;
while (n != 0) {
int c = n%10;
sum += c;
n /= 10;
}
printf("The sum is %d\n", sum);
return 0;
}

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

sorry buddy just try this out...
#include<stdio.h>
#include<conio.h>
void main()
{
int a,n,sum=0;
clrscr();
printf("Enter the number");
scanf("%d",&a);
do
{
n=a%10;
sum=sum+n;
a=a/10;
}
while(a=0);
printf("The sum of digits of the number %d is %d",a,sum);
getch();
}

i think this should work....

...
}while(a=0) makes the while loop execute only once.

#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,r;
clrscr();
printf("Enter the number");
scanf("%d",&n);
do
{
r=n%10;
s=s+r;
n=n/10;
}while(n!=0);
printf("the sum is %d",s);
getch();
}

Read this, it applies to your program. (conio, void main(), getch clrscr are bad coding habits)
Next: read this to learn how to make a senseable post
Then read this about code tags
And learning what indention is, will help you in the future

u cn jst tr ds out dat cn wrk 4 any num f long integer range sch as 123456789 etc.,

#include<stdio.h>
main()
{
int a,b,c;
long int n;
clrscr();
printf("Enter the Number: ");
scanf("%li",&n);
c=0;
while(n>0)
{
b=n%10;
c+=b;
n=n/10;
}
printf("The Sum of the
Number : %d",c);
getch();
}

/*sum of digits*/
#include<conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
int num,n,digits,r,remainder,i,sum,m;
clrscr();
n=10;
m=1;
r=0;
sum=0;/*remember to initialize variables*/
printf("Enter The No\n");
scanf("%d",&num);
printf("Enter The No of digits\n");
scanf("%d",&digits);
for(i=1;i<=digits;i++)
{
num=num-r;
r=num%n;
remainder=(r/m);
sum=sum+remainder;/*modulus operator can not be used on float*/
n=n*10;
m=m*10;
printf("%d\n",remainder);
}
printf("%d\n",sum);
getch();
}

#include <stdio.h>
main()
{
int n, sum = 0, remainder;
printf("Enter an integer\n");
scanf("%d",&n);
while(n != 0)
{
remainder = n % 10;
sum = sum + remainder;
n = n / 10;
}
printf("Sum of digits of entered number = %d\n",sum);
return 0;
}

#include <stdio.h>
#include <conio.h>
main()
{
int n, sum = 0, remainder;
printf("Enter an integer= ");
scanf("%d",&n);
while(n != 0)
{
remainder = n % 10;
sum = sum + remainder;
n = n / 10;
}
printf(" \n Sum of digits of entered number = %d.",sum);
getch();
}