Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, a, temp;
- int sum = 0;
- cout << "Enter the number n: ";
- cin >> n;
- cout << "Enter the number a (0<=a<=8): ";
- cin >> a;
- while (n>0){
- temp = n%10;
- if (temp>a){
- sum = sum + temp;
- }
- n = n/10;
- }
- cout << "Sum of n's digits greater than a: " << sum ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement