Program to find the sum of digits of a given number until
the sum becomes a single digit
Answer Posted / ashutosh shashi
int n = 123456789; //any numer of you want sum
int sum = 0;
while (n > 0)
{
int p = n % 10;
sum = sum + p;
n = n / 10;
if(n==0 && sum>9)
{
n=sum;
sum=0;
}
}
printf("%d",sum);
| Is This Answer Correct ? | 157 Yes | 63 No |
Post New Answer View All Answers
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
Write a program for finding factorial of a number.
what is the basis for selection of arrays or pointers as data structure in a program
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
Is c language still used?
How can a process change an environment variable in its caller?
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What does sizeof int return?
Explain pointer. What are function pointers in C?
What is static volatile in c?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
Explain bit masking in c?
Are comments included during the compilation stage and placed in the EXE file as well?
Which one would you prefer - a macro or a function?
What is the difference between text and binary i/o?