Education for ALL
Pages
C
C++
DL
MP
COA
NM
CG
DSA
DBMS
DC
CN
Crypto
IP
SE
SPM
OS
MC
AI
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