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 / nishant rai
#include<stdio.h>
#include<conio.h>
void 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);
getch();
}
| Is This Answer Correct ? | 13 Yes | 14 No |
Post New Answer View All Answers
What are the 4 types of programming language?
Can we declare variables anywhere in c?
Why flag is used in c?
Is c still relevant?
How can you access memory located at a certain address?
What are high level languages like C and FORTRAN also known as?
Compare interpreters and compilers.
What is the difference between c and python?
How can I do graphics in c?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
Write a program to print factorial of given number using recursion?
Are there any problems with performing mathematical operations on different variable types?
What are qualifiers in c?
What are lookup tables in c?
Which is the memory area not included in C program? give the reason