C++ Program to Calculate Sum of Digits.
#include <iostream>
using namespace std;
int main() {
int n,r,sum=0;
cout<<"Enter Number : ";
cin>>n;
while(n!=0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
cout<<"Sum is : "<<sum;
return 0;
}
Output :
C++ Program to Calculate Sum of Digits.
#include <iostream>
using namespace std;
int main() {
int n,r,sum=0;
cout<<"Enter Number : ";
cin>>n;
while(n!=0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
cout<<"Sum is : "<<sum;
return 0;
}
Output :
Hello, I'm Arjunji, Currently I'm Pursuing MCA. I like to learn something new in my free time and thinking about innovative ideas.
I believe in myself and have a positive attitude towards work which I pursue everyday.
Looking forward to learn new things every single day.
Read More
No comments:
Post a Comment