Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Error : Conflicting type for (http://www.go4expert.com/forums/error-conflicting-type-t26448/)

Raven9 6Aug2011 16:52

Error : Conflicting type for
 
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.

michael j g 6Aug2011 18:56

Re: Error : Conflicting type for
 
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

Raven9 8Aug2011 13:39

Re: Error : Conflicting type for
 
Thanks...!!:)

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


All times are GMT +5.5. The time now is 04:20.