Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int dividers(int y,int x){
- int yx;
- int d;
- int divi[100];
- if(y > x){
- yx = y;
- }
- if(x > y){
- yx = x;
- }
- for (int n = 1; n <= yx; n++){
- if ((n%y==0) && (n%x==0)){
- d += 1;
- divi[d] = n;
- }
- }
- return divi;
- }
- int main()
- {
- int x,y;
- cout << "Enter first number: ";
- cin >> x;
- cout << endl;
- cout << "Enter second number: ";
- cin >> y;
- dividers(x,y); // here it should get me the divi array.(if that is somehow possible)
- //here i want to paste them to the screen.
- for(int n = 1; n <= d; n++){
- cout<<divi[n] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment