if a five digit number is input through the keyboard, write
a program to calculate the sum of its digits.
(hint:-use the modulus operator.'%')
Answer Posted / saurabh vyas
main()
{
int num=0,sum=0,k=0;
pirntf("enter the number\n");
scanf("%d",&num);
while(num!=0);
{
k=num%10;
sum=sum+k;
num=num/10;
}
printf("%d",sum);
}
| Is This Answer Correct ? | 4 Yes | 9 No |
Post New Answer View All Answers
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
What is int main () in c?
What are data types in c language?
What is the difference between exit() and _exit() function in c?
What is difference between scanf and gets?
what is event driven software and what is procedural driven software?
5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.
What is the difference between #include
What are register variables? What are the advantage of using register variables?
Wt are the Buses in C Language
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
What is maximum size of array in c?
Is the exit() function same as the return statement? Explain.
cavium networks written test pattern ..
Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?