Computer Science, asked by kumarimadhu99935, 2 days ago

6. Write a program in C++ to calculate sum of digits?​

Answers

Answered by navanithishere
0

Answer:  C++ Program to calculate sum of digits

Explanation:

#include <iostream>  

using namespace std;  

int main()  

{  

int num,sum=0,no;    

cout<<"Enter a number: ";    

cin>>num;    

while(num>0)    

{    

no=num%10;    

sum=sum+no;    

num=num/10;    

}    

cout<<"Sum is= "<<sum<<endl;    

return 0;  

}  

Similar questions