C++ Program to Find Sum of Digits of a Number – C++ Program

By: Prof. Dr. Fazal Rehman | Last updated: October 21, 2023

C++ Program to Find the Sum of Digits of a Number – C++ Program.

Flowchart of  Sum of Digits of a Number – C++

Flowchart of Program to Find Sum of Digits of a Number - C++ Program  

C++ Source Code of Program

Output Please Enter a number: 5 The sum of series = 111105

Exercise

Find the possible mistakes in the following Shamil’s Flow Table of the Program to Find the Sum of Digits of a Number – C++ Program.
Loop condition What lines will execute Actual work to do
  i=1 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 sum=sum +k; 9=0+9 K=k*10+9; 99=9*10+9
1 time i=2 True   1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 10,11,12,13,14,15,16 sum=sum +k; 108=9+99 K=k*10+9; 999=99*10+9
2 times i=3 True   1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 10,11,12,13,14,15,16,10,11,12,13,14,15,16 sum=sum +k; 1107=108+999 K=k*10+9; 9999=999*10+9
3 time i=4 False 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 10,11,12,13,14,15,16,10,11,12,13,14,15,16,17,18   “sum of series”

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials