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 / jyoti
#include<stdio.h>
int main()
{
int n,d1,d2,d3,d4,d5,s;
printf("enter a five digit no");
scanf("%d",&n);
d5=n%10;n=n/10;
d4=n%10;n=n/10;
d3=n%10;n=n/10;
d2=n%10;n=n/10;
d1=n%10;
s=d1+d2+d3+d4+d5;
return 0;
}
| Is This Answer Correct ? | 29 Yes | 13 No |
Post New Answer View All Answers
What are the different file extensions involved when programming in C?
Explain what is wrong in this statement?
Write a program to swap two numbers without using third variable in c?
Differentiate between ordinary variable and pointer in c.
Is that possible to add pointers to each other?
Who developed c language?
Explain the difference between ++u and u++?
the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none
Describe the modifier in c?
Explain how do you search data in a data file using random access method?
What is signed and unsigned?
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
What is pointer to pointer in c language?
What are the ways to a null pointer can use in c programming language?
Explain setjmp()?