Program code:
#include<iostream>
using namespace std;
int main()
{
int num, mod , rem ,sum = 0;
char redo;
do
{
sum = 0;
cout<<"Enter any number = ";
cin>> num ;
while(num)
{
mod = num % 10 ;
num = num / 10 ;
sum = sum + mod ;
}
cout<<"\n\nSum of Digits of a Number is = " << sum ;
cout<< endl<<endl;
cout<<"Enter y for next calculation = ";
cin>>redo;
}while(redo == 'y');
return 0;
}
using namespace std;
int main()
{
int num, mod , rem ,sum = 0;
char redo;
do
{
sum = 0;
cout<<"Enter any number = ";
cin>> num ;
while(num)
{
mod = num % 10 ;
num = num / 10 ;
sum = sum + mod ;
}
cout<<"\n\nSum of Digits of a Number is = " << sum ;
cout<< endl<<endl;
cout<<"Enter y for next calculation = ";
cin>>redo;
}while(redo == 'y');
return 0;
}
No comments:
Post a Comment