Answer Posted / pooja
main()
{
int n,i,sum=0,r;
printf("enter the value");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
n=n/10;
sum=sum+r;
}
printf("\nsum of digits is %d",sum);
}
| Is This Answer Correct ? | 57 Yes | 11 No |
Post New Answer View All Answers
What is character constants?
write an interactive C program that will encode or decode a line of text.To encode a line of text,proceed as follows. 1.convert each character,including blank spaces,to its ASCII equivalent. 2.Generate a positive random integer.add this integer to the ASCII equivalent of each character.The same random integer will be used for the entire line of text. 3.Suppose that N1 represents the lowest permissible value in the ASCII code,and N2 represents the highest permissible value.If the number obtained in step 2 above(i.e.,the original ASCII equivalent plus the random integer)exceeds N2,then subtract the largest possible multiple of N2 from this number,and add the remainder to N1.Hence the encoded number will always fall between N1 and N2,and will therefore always represent some ASCII character. 4.Dislay the characters that correspond to the encoded ASCII values. The procedure is reversed when decoding a line of text.Be certain,however,that the same random number is used in decodingas was used in encoding.
What does volatile do?
What is the difference between mpi and openmp?
Why c is faster than c++?
What is adt in c programming?
What are the 5 types of organizational structures?
What is stack in c?
How can I manipulate strings of multibyte characters?
Ow can I insert or delete a line (or record) in the middle of a file?
Which is the best website to learn c programming?
Explain what is the best way to comment out a section of code that contains comments?
how do you programme Carrier Sense Multiple Access
What is pointer and structure in c?
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..