C++ Programming Code Examples C++ > Mathematics Code Examples Add Digits of Number Add Digits of Number To add digits of any number in C++ Programming, you have to ask to the user to enter the number to add their digits and display the addition result of the digits of the entered number on the output screen as shown here in the following program. Following C++ program ask to the user to enter a number to add digits of that number: /* C++ Program - Add Digits of Number */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int j, rem=0, sum=0; cout<<"Enter a Number :"; cin>>j; int temp=j; while(j>0) { rem=j%10; sum=sum+rem; j=j/10; } cout<<"Sum of the digits of "<<temp<<" is "<<sum; getch(); }