[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

C++Program

741574952

11/2/2008 5:38:00 AM

why the message "num%pow(10,n)"is wrong?
3 Answers

Salt_Peter

11/2/2008 7:40:00 AM

0

On Nov 2, 12:38 am, 741574...@qq.com wrote:
> why the message "num%pow(10,n)"is wrong?

works fine here...

#include <iostream>

int main()
{
std::cout << "num%pow(10,n)" << std::endl;
}

Seriously, in the case you meant to use the above in a statement, you
need a variable to assign the result to and a semicolon is required. i
can tell you right now that operator% won't accept an integer and a
double (which is what pow(...) will return).
What are variables n and num? peanuts? cats? fleas? bolts? keys? hmm?

So here goes a WILD guess.... [rubs crystal ball]

#include <iostream>
#include <cmath>

int main()
{
int num(1);
// int result = num % pow(num, num) // invalid operands - int %
double
int result = num % static_cast< int >( pow(num, num) );
}

If you still don't get it, then please consult the newgroup message
just below this one or the FAQ directly:

<quote>

* Include the smallest, complete and compilable program that exhibits
your
problem. As a rule, posters in comp.lang.c++ will not do homework,
but will
give helpful hints if you have shown some willingness to try a
solution.

</quote>

Juha Nieminen

11/2/2008 11:48:00 AM

0

741574952@qq.com wrote:
> why the message "num%pow(10,n)"is wrong?

Because the % operator expects two integral values and you are giving
it a floating point value?

Ron AF Greve

11/2/2008 12:00:00 PM

0

Hi,


<741574952@qq.com> wrote in message
news:cf9031d2-010c-4504-b4c9-d4c57a2d934b@u29g2000pro.googlegroups.com...
> why the message "num%pow(10,n)"is wrong?

Because it is not a minimal compilable program showing the problem?

Regards, Ron AF Greve

http://www.InformationSuper...