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 / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int n,m,m1,s=0,d,sum;
printf("\nEnter the number ");
scanf("%d",&n);
m=n%10;
d=n/10;
while(d>=10)
{
m1=d%10;
d=d/10;
s =s+m1;
}
sum=s+m+d;
printf("\nSum is %d",sum);
getch();
}
| Is This Answer Correct ? | 13 Yes | 17 No |
Post New Answer View All Answers
GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)
Explain why C language is procedural?
Why enum is used in c?
Why c is called object oriented language?
All technical questions
What are the general description for loop statement and available loop types in c?
How can I do graphics in c?
What are loops in c?
What are valid signatures for the Main function?
Explain what is the concatenation operator?
What is the use of typedef in c?
What is c variable?
What is scope rule in c?
What is the difference between class and object in c?
Explain a pre-processor and its advantages.