Program to find the sum of digits of a given number until
the sum becomes a single digit

Answer Posted / somasundaram

#include<stdio.h>
#include<conio.h>
void main()
{
unsigned int no;
clrscr();

printf("Enter number : ");
scanf("%d", &no);

if(no==0)
printf("sum = 0");
else
{
no=no%9;
if(no==0)
printf("sum = 9");
else
printf("sum = %d", no);
}

getch();
}

Is This Answer Correct ?    9 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a macro, and explain how do you use it?

623


What is %d called in c?

754


Explain low-order bytes.

619


Explain b+ tree?

618


what is recursion in C

607






What is the difference between single charater constant and string constant?

617


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

553


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

651


How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?

609


in iso what are the common technological language?

1631


What is getche() function?

603


Write a program to find the biggest number of three numbers in c?

588


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1621


How can I write a function that takes a format string and a variable number of arguments?

600


What's the difference between constant char *p and char * constant p?

651