Wednesday, 8 December 2010

algorithm for To find the sum of individual digits of a given number

Step 1: start
Step 2: read n
Step 3: initialize the s=0
Step 4: if n<0 go to Step 7
Step 5: if n!=0 go to Step 6 else go to step 7
Step 6: store n%10 value in p
Add p value to s
Assign n/10 value to n
Go to Step 5
Step 7: print the output
Step 8: stop

No comments:

Post a Comment