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 / jegadeesh
#include<stdio.h>
void main()
{
int i,j;
scanf("%d",&i);
if(i>9)
{
if((i%9)==0)
printf("The sum of digit is 9");
else
{
j=i%9;
printf("%d",j);
}
}
else
{
printf("The sum of digit is ",i);
}
}
//the above will print result as 6 if given as 12345 since
1+2+3+4+5=15 and proceeding 1+5 we get as 6.....
is this answer u are looking...
Is This Answer Correct ? | 9 Yes | 4 No |
Post New Answer View All Answers
any "C" function by default returns an a) int value b) float value c) char value d) a & b
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
Explain what are the different data types in c?
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
How many levels of indirection in pointers can you have in a single declaration?
What is the use of extern in c?
What do you mean by invalid pointer arithmetic?
When c language was developed?
Is malloc memset faster than calloc?
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
What is an auto keyword in c?
Tell me can the size of an array be declared at runtime?
write a c program in such a way that if we enter the today date the output should be next day's date.
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
What is the use of sizeof () in c?