fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int printDividers(int x)
  5. {
  6. for (int j=1; j<x+1; j++)
  7. {
  8. if (x%j==0) cout << j << ", ";
  9. }
  10. }
  11.  
  12. int main()
  13. {
  14. int z;
  15. cout << "Enter a number and the program will print out it's dividors:" << endl;
  16. cin >> z;
  17. printDividers(z);
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3416KB
stdin
5
stdout
Enter a number and the program will print out it's dividors:
1, 5,