answersLogoWhite

0


Best Answer

#include

int main()
{
int num, dig, sum = 0; /* be sure to initialize sum to 0 */

printf("Enter number:");
scanf("%d", &num); /* num is our actual number */

while (num > 0) /* While we still have digits in num */
{
dig = num % 10; /* Get the rightmost digit in num... */
sum += dig; /* and add it to sum */
num = num / 10; /* Get rid of the rightmost digit in num */
}

printf("Result: %d", sum);
return 0;
}

User Avatar

Wiki User

โˆ™ 2009-11-24 10:05:26
This answer is:
User Avatar
Study guides

Algebra

20 cards

A polynomial of degree zero is a constant term

The grouping method of factoring can still be used when only some of the terms share a common factor A True B False

The sum or difference of p and q is the of the x-term in the trinomial

A number a power of a variable or a product of the two is a monomial while a polynomial is the of monomials

โžก๏ธ
See all cards
3.74
โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…
1196 Reviews

Add your answer:

Earn +20 pts
Q: Write a c program to compute the sum of digits of a given five digit number?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a java program to compute sum of the individual digits of a given integer individual?

first read nd write all individual digits then goto sum funtion use by adding all individual digits..


How do you write a program in c to compute the power of a number without using the mathh library?

With repeated multiplication.


Write a Shell program to find the sum of cube of individual digits of a number?

no thanks


Write a c program to arrange the digits of a number in ascending order?

Computer programmers use an array to arrange digits of a number in ascending order. The program uses character array to store the digits and a quick sort feature to sort them.


Write a program to compute the roots of a quadratic equation?

lol no betch


Write a program to find the sum of squares of the given number?

Algorithm and Flowcharts for a program to compute the sum of the squares of the numbers for a given range used for loop


Can you give me a program that will compute number 1 to 5?

nr\m;laeoh9y0m g.qthnedxc In fortran: do i=1,5 write(6,*)i enddo stop end This program will write the numbers 1 to 5 on the screen.


Write a c program to find Volume and surface area of cube?

Write a c program to compute the surface area and volume of a cube


Write a pascal program that compute an area of a triangle?

{A program to compute the area of a triangle} {by Ogboin W. Meshach} Var; b,h:real; BEGIN Writeln('Triangle'); Write('Base: '); Readln(base); Write('Height: '); Readln(height); area:=0.5*base*height; Writeln('Area: ', area :0:2); End.


Write a program in pascal that calculates the area of a circle?

. Write the paschal program to compute the area and circumference of the circle while radius(r) is entered by the user


Write a program in java to enter 3 digits or more arrange the digits of the entered number in ascending order and display the result?

import java.Scanner; nagado la amom} }}


Write a program in c plus plus to compute first of non-terminal?

there is no solution of this problem...........that's it..........

People also asked