Sum of digits

Description:

Write a c++ program to find the sum of digits of the given number Test Case 1 Input (stdin) 1234 Expected Output The sum is 10 Test Case 2 Input (stdin) 367 Expected Output The sum is 16

Program :

#include <iostream>

 using namespace std;

 int main()

{

 int n,sum=0,m;

 cin>>n;

while(n>0)

{

 m=n%10;

 sum=sum+m;

 n=n/10;

 }

cout<<"The sum is "<<sum<<endl;

 return 0;

 }