In which line it displays error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sasimca007
    New Member
    • Sep 2007
    • 129

    In which line it displays error?

    1. #define CIRCUM(R) (3.14*R*R);
    2. main()
    3. {
    4. float r=1.0,c;
    5. c= CIRCUM(r);
    6. printf("n%f",c) ;
    7. if(CIRCUM(r))== 6.28)
    8. printf("nGobble dygook");
    9. }
  • arnaudk
    Contributor
    • Sep 2007
    • 425

    #2
    Read the posting guidlines before posting on this forum: Posting Homework or Coursework Questions and Answers.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by sasimca007
      In which line it displays error?


      Where do you think it displays the error?

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        If you're not sure where the error's going to be, try to compile it and the compiler will tell you where the error is. Or where it thinks the error is, which isn't always quite the same thing, especially when curly brace errors are involved.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          btw, that macro sucks and not because pi doesn't equal 3.14.

          kind regards,

          Jos

          Comment

          • Sick0Fant
            New Member
            • Feb 2008
            • 121

            #6
            Originally posted by JosAH
            btw, that macro sucks and not because pi doesn't equal 3.14.

            kind regards,

            Jos
            Is it because it computes the area instead of circumference, or is it the mere fact that he's using a macro for something like this? :-)

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Originally posted by Sick0Fant
              Is it because it computes the area instead of circumference, or is it the mere fact that he's using a macro for something like this? :-)
              Nope, have a look at that macro definition again:

              [code=c]
              #define CIRCUM(R) (3.14*R*R);
              [/code]

              that semicolon at the end is a big nono, i.e. that macro can not be used as an
              expression, e.g. CIRCUM(r)+1 but that's not the most important blooper: try to
              evaluate it for the radius 'a+b', i.e. CIRCUM(a+b). That's why that macro sucks.

              kind regards,

              Jos

              Comment

              • dtimes6
                New Member
                • Oct 2006
                • 73

                #8
                You should never compare the float or double directly.

                Comment

                Working...