#include<stdio.h>
main()
{
Int n,s,p;
clrscr();
printf("enter
the vaue for n:\n"); scanf("%d",&n);
s=0;
if(n<0)
printf("The
given number is not valid"); else
{
while(n!=0) /* check the given value =0 or not */
{
p=n%10;
n=n/10;
s=s+p;
}
printf("sum of individual digits is
%d",s);
}
getch();
}
Output:
1.Enter the value for n: 333
Sum of individual
digits is 9
2.Enter the value for n: 4733
Sum of individual digits is 17
3. Enter the value for n: -111
The given number is not valid
Conclusion : The program is error
free
VIVA QUESTIONS:
1) What is the mean
of sum of the individual digits?
Ans: Sum of the individual digits means
adding each digit in a number
2) What is positive
integer?
Ans: if the integer
value is greater than zero then it is called positive integer
3) Define
preprocessor ?
Ans:
Before compiling a process called preprocessing is done on the source code by a
program called the preprocessor.