| | |
program for finding factorial of a number using *operator overloading
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
You know what a factorial is I hope?
Then you know you need multiplication to calculate it.
The simplest program would use a for loop, something like
I'm not sure why you'd want to use overloaded operators, I guess you have to make a class Factorial.
If that's so the operator seems simple, with a body like "return f*i;" where f is a class member and i the parameter to the operator.
Then you know you need multiplication to calculate it.
The simplest program would use a for loop, something like
C++ Syntax (Toggle Plain Text)
long fact = 1; // request is the number of which the factorial is requested for (int i=1; i<=request; fact *= i++);
I'm not sure why you'd want to use overloaded operators, I guess you have to make a class Factorial.
If that's so the operator seems simple, with a body like "return f*i;" where f is a class member and i the parameter to the operator.
![]() |
Similar Threads
- Pos/Pre fix operator overloading question. (C++)
- Calculating a factorial of a number using C# (C#)
- finding modulo of a number in masm (Assembly)
- Help in finding 1500`th ugly number. (C++)
- Code Snippet: finding factorial of a number. (C)
- help me to do operator overloading n class (C++)
- Operator Overloading Question (C++)
Other Threads in the C++ Forum
- Previous Thread: unresolved external symbol when using a hashtable class
- Next Thread: C++ Compilers
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






