write a program to gat the digt sum of a number (et. 15=
>1+5=6)
Answer Posted / santhosh kumar
#include<stdio.h>
#include<string.h>
int main ()
{
char no[100];
char num[2];
int i;
int length = 0;
int sum = 0;
memset(num, 0, 2);
printf("Enter the number: ");
gets(no);
length = strlen(no);
for(i=0; i<length; i++)
{
num[0] = no[i];
sum += atoi(num);
}
printf("Sum = %d", sum);
return 0;
}
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
How can you restore a redirected standard stream?
What is break statement?
Why can’t we compare structures?
What is a pointer value and address in c?
How can you return multiple values from a function?
What are c preprocessors?
What is c standard library?
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 the disadvantages of a shell structure?
Write the syntax and purpose of a switch statement in C.
What is d scanf?
Explain the difference between strcpy() and memcpy() function?
What is the difference between break and continue?
What are static variables in c?
what is ur strangth & weekness