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 are the types of operators in c?
What are the salient features of c languages?
What is getch () for?
How we can insert comments in a c program?
Describe wild pointers in c?
Explain data types & how many data types supported by c?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
Is fortran still used today?
Is swift based on c?
What is the symbol indicated the c-preprocessor?
What is wrong with this initialization?
Is main an identifier in c?
Explain what is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
State the difference between realloc and free.
Write a program to know whether the input number is an armstrong number.