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

Why pointers are used?

633


What is the role of && operator in a program code?

568


Why does not c have an exponentiation operator?

629


What is file in c preprocessor?

654


Can a void pointer point to a function?

573






How can you increase the size of a statically allocated array?

617


What is the best style for code layout in c?

632


What does 3 mean in texting?

617


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1497


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

2413


How can I recover the file name given an open stream?

556


What are static variables in c?

629


What is pointer to pointer in c?

634


code for find determinent of amatrix

1519


What do header files do?

603