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
What do you mean by keywords in c?
What are 'near' and 'far' pointers?
What is spark map function?
Explain what is the purpose of "extern" keyword in a function declaration?
Write a program for Overriding.
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
What is meant by recursion?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare. You will then tabulate this information in another file.
What is use of integral promotions in c?
What is difference between array and structure in c?
Explain what are header files and explain what are its uses in c programming?
Explain two-dimensional array.
What is difference between scanf and gets?
What is getch () for?