Advertisement
SelinD

ex27

Jun 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. void sumazec(int a,int n,int &s)
  5. {
  6. s=0;
  7. int p=1,i,nr;
  8. for(i=1;i<=n;i++)
  9. {
  10. p=p*10;
  11. }
  12. nr=p/a;
  13. while(nr>0)
  14. {
  15. s=s+nr%10;
  16. nr=nr/10;
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. int n,p,s;
  23. sumazec(4,3,s);
  24. cout<<s;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement