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 #error and use of it?
What is dangling pointer in c?
Write a program to know whether the input number is an armstrong number.
What is calloc in c?
What is the basic structure of c?
What is the scope of global variable in c?
any function have arguments one or more OR not . it is compulsary a) any function compulsary have one or more arguments b) any function did not have arguments. It is not compulsary c) it is optional it is not compulsary d) none of the above
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
What does typedef struct mean?
How do I copy files?
Can we increase size of array in c?
Why string is used in c?
What does 3 periods mean in texting?
Is c procedural or functional?