Advertisement
Dizzy3113

Untitled

Nov 17th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void numar(int n, int c1, int c2, int &x)
  6. {
  7. x=0;
  8. while(n)
  9. {
  10. if(n%10>=c1 && n%10<=c2)
  11. x=x+n%10;
  12. n=n/10;
  13. }
  14. }
  15. int main()
  16. {
  17. int x;
  18. numar(123, 2, 7, x);
  19. cout<<x;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement