Education for ALL
Pages
C
C++
MP
NM
CG
COA
CN
DBMS
Crypto
IP
SE
SPM
DSA
OS
MC
C++ program to find the sum of the digits of a given number
#include <iostream>
using namespace std;
int main()
{
int n=12345,digit,sum=0;
while(n!=0)
{
digit=n%10;
sum+=digit;
n=n/10;
}
cout<<"Sum of ALL digits is: "<<sum;
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
No comments:
Post a Comment