Education for ALL
Pages
DL
MP
MC
COA
ES
NM
CG
OS
IP
DC
CN
CNS
Cryptography
C
C++
DSA
DBMS
SAD
SE
SPM
IoT
Blockchain
DS
AI
ML
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