Error : Conflicting type for

Discussion in 'C' started by Raven9, Aug 6, 2011.

  1. Raven9

    Raven9 New Member

    Joined:
    Aug 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    main( )
    {
    float a, b ;
    printf ( "\nEnter any number " ) ;
    scanf ( "%f", &a ) ;
    b = square ( a ) ;
    printf ( "\nSquare of %f is %f", a, b ) ;
    }
    square ( float x )
    {
    float y ;
    y = x * x ;
    return ( y ) ;
    }
    

    This Program gives me error of 'conflicting type for' in code blocks build.
    And Whenever i run this program then it does'nt show the output in float but in integer type. Please Give the reason for this.... And also guide me how to get floating type output from this program.
     
    Last edited by a moderator: Aug 7, 2011
  2. michael j g

    michael j g New Member

    Joined:
    Nov 3, 2010
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Canteen at a school
    Location:
    SOUTH AUSTRALIA
    Excuse me i do not know but did you miss "int"
    I tryed copying your code and i wouldent know but it may take a problem away?
    Not sure:
    Your Code:

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main( )
    {
    float a, b ;
    printf ( "\nEnter any number " ) ;
    scanf ( "%f", &a ) ;
    b = square ( a ) ;
    printf ( "\nSquare of %f is %f", a, b ) ;
    }
    square ( float x )
    {
    float y ;
    y = x * x ;
    return ( y ) ;
    }
    
    i have tryed some of the skills playing around with it as well.
    I do not know but read the Messages and right click them and go to location.
    you will find the location of the problem!

    They are mostly tips.!
    PS: the code above that i copyed has an added int at location "int main()"

    Sorry and Thanks!
    Tryed to help
     
    Last edited by a moderator: Aug 7, 2011
  3. Raven9

    Raven9 New Member

    Joined:
    Aug 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Thanks...!!:)

    Well After restarting my PC it Does'nt give me that type of error also..!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice