By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,483 Members | 1,612 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,483 IT Pros & Developers. It's quick & easy.

(part 11) Han from China answers your C questions

P: n/a
A new learner's question

Flash Gordon wrote:
>fl*****@126.com wrote:
>I'm a student who is studying program firstly.Recently I wrote
some code below in a program.
for(i=1;i<=count;++i){
number[i]=integer % pow(10,i)/ pow(10,i-1);
}
But my compiler(VC) told me: '%' : illegal,
right operand has type 'double'.Please tell me what does it mean?

It means the right hand operand of % in your code is of type double
(because that is what pow()/pow() gives) and that is not allowed.
To the OP, please be aware that Flash Gordon has a history of either
deliberately misleading and "miss-informing" posters to this
newsgroup or providing facile answers with which to amuse himself.

In this case, both. Facile because Flash Gordon did not tell you
substantially anything more than your compiler had told you. Misleading
and "miss-informing" in that what he did add to the compiler output
is an attempt to confuse your understanding of the precedence and
associativity rules in C. The right-hand operand to % is pow(), not
pow()/pow().

Please refer to the other posts in your thread for more informative
replies.
[snip remainder of garbage]
Yours,
Han from China

Nov 4 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 4 Nov, 19:20, Nomen Nescio <nob...@dizum.comwrote:
A new learner's question
Flash Gordon wrote:
flen...@126.com wrote:
I'm a student who is studying program firstly.Recently I wrote
some code below in a program.
* * for(i=1;i<=count;++i){
* *number[i]=integer % pow(10,i)/ pow(10,i-1);
* * }
But my compiler(VC) told me: '%' : illegal,
right operand has type 'double'.Please tell me what does it mean?
It means the right hand operand of % in your code is of type double
(because that is what pow()/pow() gives) and that is not allowed.

To the OP, please be aware that Flash Gordon has a history of either
deliberately misleading and "miss-informing" posters to this
newsgroup or providing facile answers with which to amuse himself.
this is untrue. Please check recent posts of both parties
and judge which is the more likely to intentionally mislead.

<snip>
Nov 5 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.