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 / aha na
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,sum=0;
clrscr();
printf("\n enter a number",i);
scanf("%d",&i);
while(i<=0)
{
j=i%10;
sum=sum+j;
i=i/10;
}
printf("\n the sum of the digits
are:%d\n");
getch();
}
| Is This Answer Correct ? | 14 Yes | 30 No |
Post New Answer View All Answers
What are type modifiers in c?
Write a program in c to replace any vowel in a string with z?
I came across some code that puts a (void) cast before each call to printf. Why?
how to introdu5ce my self in serco
What is difference between %d and %i in c?
Why can’t we compare structures?
What is a buffer in c?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.
What is the use of getchar functions?
How can you access memory located at a certain address?
What is a struct c#?
How pointer is different from array?
Explain how does free() know explain how much memory to release?
Differentiate between #include<...> and #include '...'