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 / synner

#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
long int num;
int sum=0,temp;
clrscr();
printf("Enter the numbe\n");
scanf("%ld",&num);
while(num!=0)
{
temp=num%10;
sum=sum+temp;
num=num/10;
}
printf("%d",sum);
getch();
}

Is This Answer Correct ?    11 Yes 20 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

in multiple branching construct "default" case is a) optional b) compulsarily c) it is not include in this construct d) none of the above

623


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

1576


Differentiate between new and malloc(), delete and free() ?

663


Describe how arrays can be passed to a user defined function

774


Which header file is essential for using strcmp function?

930






How can you increase the size of a dynamically allocated array?

636


What is the meaning of && in c?

543


What is static function in c?

622


Explain how can I read and write comma-delimited text?

645


What tq means in chat?

575


Are the variables argc and argv are local to main?

780


Explain output of printf("Hello World"-'A'+'B'); ?

967


Describe newline escape sequence with a sample program?

643


What oops means?

574


Why c language is called c?

561