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 value is returned to operating system after program execution?
Why clrscr is used in c?
What are local variables c?
Why is %d used in c?
how to introdu5ce my self in serco
How many types of operators are there in c?
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
What is a program flowchart and explain how does it help in writing a program?
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
Write a program to swap two numbers without using third variable in c?
What is a macro in c preprocessor?
Is boolean a datatype in c?
Why do we use header files in c?
Why do we use static in c?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.