Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- void show( int *arr ,int num );
- int main(int argc, char *argv[])
- {
- int num=0;
- int numfactor=0;
- int numarry=0;
- char error[20];
- cout << "what number do you want to factor: ";
- while (!(cin >> num)) {
- cout <<"try again";
- cin >> error;
- }
- for (int i=1;i<=num;i++)
- if (!(num % i))
- numfactor++;
- int * factor =new int [numfactor];
- for (int i=1;i<=num;i++)
- if (!(num % i)) {
- cout <<i<<"\n";
- factor[numarry];
- numarry++;
- }
- cout <<num << " has these factors ";
- show(factor,numfactor);
- cout <<"\n";
- system("PAUSE");
- return EXIT_SUCCESS;
- }
- void show (int arr[] ,int x)
- {
- cout <<arr[0];
- for (int i=1;i < x;i++)
- cout <<","<<arr[i];
- }
Add Comment
Please, Sign In to add comment