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 / jyoti
#include<stdio.h>
int main()
{
int n,d1,d2,d3,d4,d5,s;
printf("enter a five digit no");
scanf("%d",&n);
d5=n%10;n=n/10;
d4=n%10;n=n/10;
d3=n%10;n=n/10;
d2=n%10;n=n/10;
d1=n%10;
s=d1+d2+d3+d4+d5;
return 0;
}
| Is This Answer Correct ? | 29 Yes | 13 No |
Post New Answer View All Answers
Is main a keyword in c?
Which built-in library function can be used to match a patter from the string?
What is the best style for code layout in c?
what do the 'c' and 'v' in argc and argv stand for?
code for quick sort?
Explain the use of 'auto' keyword in c programming?
#define f(g,h) g##h main O int i=0 int var=100 ; print f ("%d"f(var,10));} wat would be the output??
What is the purpose of realloc()?
What is d'n in c?
State two uses of pointers in C?
Is register a keyword in c?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
How do you define CONSTANT in C?
I need testPalindrome and removeSpace
#include
What are compound statements?