answersLogoWhite

0

Well, it's very hard to write a flowchart in text, so I'll give you some pseudo code instead.

int number = the given number

int sum = 0

loop while number is not 0

sum = sum + (number mod 10)

number = number / 10

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
RossRoss
Every question is just a happy little opportunity.
Chat with Ross
More answers

#include
#include
void main()
{
int n,sum,r;
clrscr();
printf("Enter an Integer: ");
scanf("%d",&n);
sum=0;
while(n>0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("Sum of Digits: %d",sum);
getch();
}

output:
Enter an Integer:
1234
Sum of Digits: 10




1. Start the program.
2. Input n.
3. Initialize as sum=0;
4.using while loop test condition as (n>0)
5. If this derives to true then next move to body of the loop.
6. body of the loop.
7. Process as follows
i. Store the remainder in r by Modulo Division the given number by 10.
r=n%10;
ii. Add the remainder to the summation
sum=sum+r;
iii. Again divide the n by 10 and store the value in n.
n=n/10;
8. Again the loop tests for n>0
9. When n becomes less than 0 the loop terminates
10. Finally the out put prints the sum of digits of a given integer

User Avatar

Wiki User

15y ago
User Avatar

sum of individual digit of a positive integer

User Avatar

Wiki User

14y ago
User Avatar

the sum of individual digits of a given integer number

User Avatar

Wiki User

16y ago
User Avatar

draw a flow chart to arange the given data in ascending order

User Avatar

Wiki User

13y ago
User Avatar

2

User Avatar

Wiki User

12y ago
User Avatar

Add your answer:

Earn +20 pts
Q: Individual digits sum with flowchart and algorithm?
Write your answer...
Submit
Still have questions?
magnify glass
imp