//Finds the posetive factors of postetive integers //Created by Gilad "Speaker For The Dead" Barlev //Final programming edit on 18/1/02 (D/M/Y) //Final internal documentation edit on 18/1/02 (D/M/Y) #include #include #include #include using namespace std; //function prototypes void findFactor(int, int); void clrScr(); int main() {//main program //intro cout << "Speaker For The Dead Presents..." << endl << endl; getch (); //declare variables int num; float max; int factor = 0; //load file ifstream fin; ofstream fout; fin.open("factor finder.dat"); if (fin.is_open() ) {//cancel cout << "Erase old file? (Y/N)"; char x; cin >> x; if (x != 'y' && x != 'Y') goto Credits; }//end cancel fin.close(); //get number cout << "FACTOR FINDER 1.0" << endl << endl << "Enter your posetive integer=? "; cin >> num; fout.open("factor finder.dat"); fout << "Factors of " << num << ": " << endl; fout.close(); //calculate maximim max = sqrt(num); //get factors while (factor <= max) {//factor loop factor = factor + 1; findFactor(num, factor); }//end factor loop getch(); Credits: //credits clrScr(); cout << endl << "This program was made by Speaker For The Dead for entertainment purposes only." << endl << "For problems with this program or more information on Speaker For The Dead," << endl<< "Please send an email to the_sftd@yahoo.com" << endl; return 0; } /*****PROGRAM DEFINED FUNCTIONS*****/ void findFactor(int num, int factor) {//factor finder int remainder = num % factor; if (remainder == 0) {//factor found ofstream fout; fout.open("factor finder.dat", ios::app); cout << factor << "/"; cout << num / factor << " "; fout << factor << "/" << num / factor << " "; fout.close(); }//end factor found }//end factor finder void clrScr() {//clear screen int x; for (x = 0; x < 25; x++) { cout << endl; } }//end clear screen //This program was made by Speaker For The Dead for entertainment purposes only. //For problems with this program or more information on Speaker For The Dead, //Please send an email to the_sftd@yahoo.com