C++ Programming Code Examples C++ > Mathematics Code Examples program to find sum of digits of a number program to find sum of digits of a number Sum of digits means add all the digits of any number, for example we take any number like 358. Its sum of all digit is 3+5+8=16. Using given code we can easily write c++ program. #include<iostream.h> #include<conio.h> void main() { int a,no,sum=0; clrscr(); cout<<"Enter any num : "; cin>>no; while(no>0) { a=no%10; no=no/10; sum=sum+a; } cout<<"\nSum of digits: "<<sum; getch(); }