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
Are global variables static in c?
Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.
What is array in c with example?
What is .obj file in c?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
Can you write a programmer for FACTORIAL using recursion?
What are the different types of linkage exist in c?
What is the best organizational structure?
What is character constants?
What is masking?
Can you apply link and association interchangeably?
Explain about the constants which help in debugging?
Write a program to swap two numbers without using the third variable?
What are the types of operators in c?
What are the advantages of union?