write a c++ program to find the sum of digit of a number
Answers
Answered by
2
Answer:
#include<iostream>
using namespace std;
int main() {
int x, s = 0;
cout << "Enter the number : ";
cin >> x;
while (x != 0) {
s = s + x % 10;
x = x / 10;
}
cout << "\nThe sum of the digits : "<< s;
}
output
Enter the number : 236214828
The sum of the digits : 36
Similar questions