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 sizeof array in c?

597


Explain what is the benefit of using const for declaring constants?

618


Who developed c language and when?

588


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2204


Why c is a procedural language?

587






Explain setjmp()?

661


Explain enumerated types.

602


Why do we use static in c?

636


What is an endless loop?

806


Can we change the value of static variable in c?

568


Are the variables argc and argv are always local to main?

576


How do you define structure?

571


How is pointer initialized in c?

589


Why we not create function inside function.

1753


Why isn't it being handled properly?

647