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

Answer Posted / suvabrata das

#include<stdio.h>
#include<conio.h>
void main()
{
int n,c=0,r,i;
clrscr();
printf("enter no.");
scanf("%d",&n);
while(n>0)
{
{
r=n%10;
c=c+r;
n=n/10;
}
if(c>9)
{
n=c;
c=0;
}
}
printf("%d",c);
getch();
}

Is This Answer Correct ?    58 Yes 34 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hi send me sample aptitude papers of cts?

1858


What is wrong with this declaration?

826


What is the difference between volatile and const volatile?

743


What is the use of function overloading in C?

877


What is logical error?

835


provide an example of the Group by clause, when would you use this clause

1946


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

1896


Can you mix old-style and new-style function syntax?

848


What is the method to save data in stack data structure type?

838


How do you define a function?

773


What is the difference between text and binary modes?

857


What is the value of uninitialized variable in c?

781


What do you mean by dynamic memory allocation in c?

832


What does a pointer variable always consist of?

860


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4388