Try something like this (if i understood what you wanted correctly that is)
Code:double randOper(double a, double b) { switch(rand()%4) { case 0: return a+b; case 1: return a-b; case 2: return a*b; case 3: return a/b; // Div by zero? } }
| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | VB Forums | Developer.com |
|
Results 1 to 12 of 12
Thread: Random mathmatical operatorThreaded View
|
Click Here to Expand Forum to Full Width |