| | |
factorial
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
So...what/where is the method you've tried? Without providing you the answer...here is a basic outline:
The above isn't complete nor tested. Also, in the future, before posting, search the forums to see if someone else had the same problem/assignment. We are willing to help, but we don't want to waste time doing the same thing over and over again...In the factorial function, you could try something like this:
hope this helps.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <cctype> #include <iomanip> #include <cmath> #include <fstream> #include <string> using namespace std; int main(void) { int num;//number to get it's factorial cout << "Please enter a positive number: "; cin >> num;//user enters number if (num < 0) { cout << "That is not a positive number.\n"; } else { cout << num << " factorial is: " << factorial(num) << endl; }
C++ Syntax (Toggle Plain Text)
int factorial(int ) { int temp; if(num <= 1) return 1; //figure out the simple calculaltion return temp; }//end for factorial
I shot the sheriff....but I didn't shoot the deputy
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
ok ok...totally missed that one...i didn't see another thread started by jbstin...the title of the threads were different...so i just went right in...my eyes need tested anyways...and AD...i'm not in kindergarden yet...so i can't read too well.
Last edited by zandiago; Nov 17th, 2007 at 10:03 am.
I shot the sheriff....but I didn't shoot the deputy
![]() |
Similar Threads
- factorial using a for loop (C++)
- Factorial? (C++)
- Factorial program (Java)
- Calculate the factorial of a number (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: C++ copy file
- Next Thread: call and sms blocker
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






