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
hi send me sample aptitude papers of cts?
What is wrong with this declaration?
What is the difference between volatile and const volatile?
What is the use of function overloading in C?
What is logical error?
provide an example of the Group by clause, when would you use this clause
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
Can you mix old-style and new-style function syntax?
What is the method to save data in stack data structure type?
How do you define a function?
What is the difference between text and binary modes?
What is the value of uninitialized variable in c?
What do you mean by dynamic memory allocation in c?
What does a pointer variable always consist of?
Write a c program to build a heap method using Pointer to function and pointer to structure ?