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 / pavan kumar
#include<stdio.h>
int main()
{
int a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,sum;
printf("Enter the five digit number:");
scanf("%d",&sum);
a=sum%10;
b=sum/10;
c=b%10;
d=b/10;
e=d%10;
f=d/10;
g=f%10;
h=f/10;
printf("sum of the digits:%d",a+c+e+g+h);
}
| Is This Answer Correct ? | 7 Yes | 4 No |
Post New Answer View All Answers
What are structure members?
What is merge sort in c?
What is c system32 taskhostw exe?
Using which language Test cases are added in .ptu file of RTRT unit testing???
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
What are the various types of control structures in programming?
How do you use a pointer to a function?
How can I access an I o board directly?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
What is a nested loop?
What is header file definition?
Why c is called a middle level language?
What are global variables?
What are data types in c language?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM