This article describes about the program Sum of a digit in C/C++. Let us discuss about the digit sum or sub of a digit system.
Digit sum or Sum of a Digit
In mathematics the digit sum of a given integer is the sum of all its digits. That means the digit sum of 65001 is calculated as 6+5+0+0+1 = 12.
Program to Show Sum of a Digit
cout<<"This program will show Sum of a given digit."<<endl<<endl;
cout<<"What is the digit ?. Give a integer number or digit. "<<endl; cin>>a;
cout<<endl<<"Sum of given digit "<<n<<" is :"<<p;