Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int tayExp() {
- int choice, maxLoops=10;
- double number = 1;
- int iter, i;
- float result=1.0f;
- double fact=1.0, pow=1.0;
- cout << "To what degree would you like to estimate e?: ";
- cin >> number;
- cout << endl << "Doing some math..." << endl;
- result = 0.000000000000f;
- iter = 0;
- while ( iter < maxLoops ) {
- fact = 1;
- pow = 1;
- for ( i = 0; i < iter; i++ ) {
- pow *= number;
- }
- for ( i = iter; i > 1; i-- ) {
- fact *= i;
- }
- result += pow/fact;
- iter++;
- cout << "*" << iter << " * " << result << "*" << endl;
- if ( (iter % 9) == 0 ) {
- cout << "Would you like to see ten more? (1 for yes, 0 for no): ";
- cin >> choice;
- switch ( choice ) {
- case 0:
- return 0;
- break;
- case 1:
- maxLoops += 10;
- continue;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment