(part 11) Han from China answers your C questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nomen Nescio

    (part 11) Han from China answers your C questions

    A new learner's question

    Flash Gordon wrote:
    >flenovo@126.co m wrote:
    >I'm a student who is studying program firstly.Recentl y I wrote
    >some code below in a program.
    > for(i=1;i<=coun t;++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

  • Nick Keighley

    #2
    Re: (part 11) Han from China answers your C questions

    On 4 Nov, 19:20, Nomen Nescio <nob...@dizum.c omwrote:
    A new learner's question
    Flash Gordon wrote:
    flen...@126.com wrote:
    I'm a student who is studying program firstly.Recentl y I wrote
    some code below in a program.
        for(i=1;i<=coun t;++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>

    Comment

    Working...