Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int F(int n) {
- if (n % 10 > 0) {
- return(n % 10);
- }
- if (n == 0) {
- return 0;
- }
- return F(n / 10);
- }
- int main()
- {
- int p, q;
- int s = 0;
- cout << "Enter p and q" << endl;
- cin >> p >> q;
- while (p >=0 && q >=0)
- {
- for (int i = p; i <= q; i++) {
- s += F(i);
- }
- cout << "There is the sum " << s << endl;
- cin >> p >> q;
- s = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement