how to find sum of digits in C?

Answer Posted / sarthak patwal

#include <stdio.h>
#include <conio.h>

void main()
{
clrscr();
int a,b,c,d;
printf ("Enter the number");
scanf ("%d",a);
b=a%10;
c=a/10;
d=b+c;
printf ("The sum of digits is %d",d);
getch();
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sizeof in c?

565


What is pointer and structure in c?

563


How does selection sort work in c?

617


Did c have any year 2000 problems?

647


Why & is used in scanf in c?

616






Explain what math functions are available for integers? For floating point?

608


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1979


What is null in c?

594


what is the basis for selection of arrays or pointers as data structure in a program

3782


What is assignment operator?

620


Should I learn data structures in c or python?

574


hi send me sample aptitude papers of cts?

1648


What is calloc malloc realloc in c?

587


What is file in c language?

572


What is the explanation for modular programming?

681