| | |
Need help with the program i have written i am unable to correct the problems. please
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2004
Posts: 3
Reputation:
Solved Threads: 0
Need help with the program i have written i am unable to correct the problems. please
0
#1 Oct 26th, 2004
hello!
i am a brand new user to this site ihope that my experence with this site would be better than previous ones, i am studying BS(computer science), recently i had trouble with a program that ihave made well that thing is that its is complete and working as well but there are problems with it i am sending the program as .cpp file i hope people at dani web will help me in correcting the program most of the problem is with the part where there is modulus and factorial function.
i am a brand new user to this site ihope that my experence with this site would be better than previous ones, i am studying BS(computer science), recently i had trouble with a program that ihave made well that thing is that its is complete and working as well but there are problems with it i am sending the program as .cpp file i hope people at dani web will help me in correcting the program most of the problem is with the part where there is modulus and factorial function.
Re: Need help with the program i have written i am unable to correct the problems. pl
0
#2 Oct 26th, 2004
What are you trying to do with those two functions? It's clearly not a simple factorial or modulo calculation, so unless you describe what the problem is, we can't help. Though I can tell you right now that your power function isn't going to work like you expect.
>i=a^b;
^ is the bitwise exclusive OR operator, not the power operator. C++ doesn't have such an operator.
>i=a^b;
^ is the bitwise exclusive OR operator, not the power operator. C++ doesn't have such an operator.
I'm here to prove you wrong.
Re: Need help with the program i have written i am unable to correct the problems. pl
0
#4 Oct 27th, 2004
Power is a function declared in the <cmath> header:
Modulus does have an operator (%), but it only works for integer values. For floating-point, you need to use the fmod function declared in the <cmath> header.
N! is easy to calculate:
C++ Syntax (Toggle Plain Text)
#include <cmath> #include <iostream> using namespace std; int main() { cout<< pow ( 2, 4 ) <<endl; }
N! is easy to calculate:
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int factorial ( int n ) { int r = n; while ( --n > 0 ) r *= n; return r; } int main() { cout<< factorial ( 5 ) <<endl; }
I'm here to prove you wrong.
![]() |
Similar Threads
- What's the HARDEST program you've written? (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: dynamic polymorphish in c++
- Next Thread: Error in c++ program
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






