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
WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.
Explain the meaning of keyword 'extern' in a function declaration.
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
What is the difference between volatile and const volatile?
Explain what standard functions are available to manipulate strings?
.find the output of the following program? char*myfunc(char*ptr) { ptr +=3; return (ptr); } int main() { char*x,*y; x="HELLO"; y=myfunc(x); printf("y = %s ",y); return 0; }
int i=10; printf("%d %d %d", i, i=20, i);
how do you write a function that takes a variable number of arguments? What is the prototype of printf () function?
What is the process of writing the null pointer?
How can this be legal c?
Why is c faster?
What is the benefit of using const for declaring constants?
"%u" unsigned integer print the a) address of variable b) value of variable c) name of a variable d) none of the above
Can a function argument have default value?
Is c dynamically typed?