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
World Languages,
3 months ago
Physics,
3 months ago
English,
6 months ago
Math,
6 months ago
English,
11 months ago
Science,
11 months ago
Computer Science,
11 months ago