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
Explain the use of bit fieild.
What is a pointer in c?
what is reason of your company position's in india no. 1.
Are local variables initialized to zero by default in c?
What is the difference between a function and a method in c?
In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]
What are conditional operators in C?
hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .
Is there a way to switch on strings?
What are the different types of pointers used in c language?
What is maximum size of array in c?
How can you find out how much memory is available?
Do variables need to be initialized?
What is c language & why it is used?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?