write a program to sum of its digit with using control
structure or with out using loop. for ex: let the number is
25634 then answer will be=2+5+6+3+4=20
Answer Posted / rama krishna sidhartha
#include <stdio.h>
#include<conio.h>
void main()
{
int s=0,c,n;
clrscr();
printf("\n ENTER A VALUE : ");
scanf("%d",&n);
while(n>0)
{
c=n%10;
s=s+c;
n=n/10;
}
printf("\n THE SUM OF INDIVIDUAL DIGITS : %d",s);
getch();
}
| Is This Answer Correct ? | 10 Yes | 10 No |
Post New Answer View All Answers
What do you mean by command line argument?
In a header file whether functions are declared or defined?
Give differences between - new and malloc() , delete and free() ?
What is the difference between if else and switchstatement
What is the use of ?
Explain the difference between #include "..." And #include <...> In c?
Is it possible to have a function as a parameter in another function?
What are the types of variables in c?
What is derived datatype in c?
How can you determine the size of an allocated portion of memory?
How can I sort a linked list?
What is conio h in c?
What is typedef struct in c?
How can this be legal c?
What is the purpose of macro in C language?