Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Input number" << endl;
- int a;
- cin >> a;
- int b=a;
- int c;
- int sum = 0;
- do {
- c = b % 10;
- b = b / 10;
- sum = sum + c;
- } while (b != 0);
- cout << sum<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement