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 / amit amar mahesh bhava
#include<sthio.h>
#include<conio.h>
void main()
{
int a,b,c,d,e,f,g,h,i,j,k,l;
printf("enter a five digit number");
scanf("%d",&a);
b=a%10;
c=a/10;
d=c%10;
e=c/10;
f=e%10;
g=e/10;
h=g%10;
i=g/10;
j=i%10;
k=i/10;
l=b+d+f+h+j;
printf("sum of the digit=%d",l);
getch();
}
| Is This Answer Correct ? | 7 Yes | 5 No |
Post New Answer View All Answers
Explain how can you be sure that a program follows the ansi c standard?
Is c call by value?
Hai what is the different types of versions and their differences
Can you explain the four storage classes in C?
What is function prototype in c with example?
What is meant by initialization and how we initialize a variable?
Explain union.
Difference between goto, long jmp() and setjmp()?
What is LINKED LIST? How can you access the last element in a linked list?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
Explain the meaning of keyword 'extern' in a function declaration.
What is meant by preprocessor in c?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
What is the use of linkage in c language?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +