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 / revanth kumar.p
include<stdio.h>
#include<conio.h>
int main()
{
int num,len = 1,a,b;
printf("Enter a number");
scanf("%d",&num);
while(num >= 10)
{
num = num/10;
len++;
}
printf("%d",len);
a=len;
a=len*(len+1)%2;
printf("\n%d",a);
b=len;
b=len*(len+1)/2;
printf("\n%d",b);
a=a+b;
printf("\n%d",a);
getch();
}
| Is This Answer Correct ? | 4 Yes | 9 No |
Post New Answer View All Answers
What is the meaning of 2d in c?
what is the significance of static storage class specifier?
What is the hardest programming language?
What is const volatile variable in c?
How can I invoke another program or command and trap its output?
Which is the best website to learn c programming?
What is pass by reference in functions?
Differentiate between #include<...> and #include '...'
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
What is static volatile in c?
What are the 4 data types?
What is optimization in c?
How many bytes are occupied by near, far and huge pointers (dos)?
What is a floating point in c?
What are the three constants used in c?