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 / aha na
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,sum=0;
clrscr();
printf("\n enter a number",i);
scanf("%d",&i);
while(i<=0)
{
j=i%10;
sum=sum+j;
i=i/10;
}
printf("\n the sum of the digits
are:%d\n");
getch();
}
| Is This Answer Correct ? | 14 Yes | 30 No |
Post New Answer View All Answers
What is putchar() function?
What is spaghetti programming?
What is #line used for?
How can I read/write structures from/to data files?
What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?
Explain 'far' and 'near' pointers in c.
Can we declare variable anywhere in c?
Is it fine to write void main () or main () in c?
How can a string be converted to a number?
How can type-insensitive macros be created?
Tell me when would you use a pointer to a function?
How can you be sure that a program follows the ANSI C standard?
Write the syntax and purpose of a switch statement in C.
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What is a c token and types of c tokens?