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 / synner
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
long int num;
int sum=0,temp;
clrscr();
printf("Enter the numbe\n");
scanf("%ld",&num);
while(num!=0)
{
temp=num%10;
sum=sum+temp;
num=num/10;
}
printf("%d",sum);
getch();
}
| Is This Answer Correct ? | 11 Yes | 20 No |
Post New Answer View All Answers
Explain do array subscripts always start with zero?
Why can't I perform arithmetic on a void* pointer?
What is difference between constant pointer and constant variable?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
Why we use conio h in c?
What is "Duff's Device"?
What are global variables and explain how do you declare them?
What is the purpose of scanf() and printf() functions?
List some applications of c programming language?
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
What is a static variable in c?
What is function prototype in c with example?
What is I ++ in c programming?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
What are the advantages of using linked list for tree construction?