int main( int argc, char *argv[] )
{
float a, b;
a = 2;
b = f( a ); // The C compiler has NOT seen the definition of float f(float x)
// 1. Input conversion ???: float a --> ???
// 2. Output conversion ???: ??? --> float
printf("b = %f\n", b);
}
float f( float x ) // This definition is too late !!
{
float r; // Define a local variable
printf("Input parameter = %f\n", x);
r = x * x; // Statement
return ( r ); // Return statement
}
|
|
to provide the function prototpe information:
float f( float x ); // Function prototype (function declaration)
int main( int argc, char *argv[] )
{
float a, b;
a = 2;
b = f( a ); // The C compiler knows that: float f(float x)
// 1. Input conversion: no conversion necessary
// 2. Output conversion: no conversion necessaty
printf("b = %f\n", b);
}
float f( float x ) // This definition is too late !!
{
float r; // Define a local variable
printf("Input parameter = %f\n", x);
r = x * x; // Statement
return ( r ); // Return statement
}
|
Experiment 2B:
Program: /home/cs255000/demo/c/set1/experiment2b.c cs255 (1744)> a.out Input parameter = 2.000000 b = 4.000000 |