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
Explain what’s a signal? Explain what do I use signals for?
How do we print only part of a string in c?
How many bytes are occupied by near, far and huge pointers (dos)?
How to write a code for implementing my own printf() and
scanf().... Please hep me in this... I need a guidance...
Can you give an coding for c... Please also explain about
the header files used other than #include
Difference between macros and inline functions? Can a function be forced as inline?
What is the modulus operator?
What is the value of h?
What is a void * in c?
What is extern variable in c with example?
what is stack , heap ,code segment,and data segment
What are pointers?
how to find anagram without using string functions using only loops in c programming
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.
Can math operations be performed on a void pointer?
What are lookup tables in c?