Hi,
I am trying to work on a "simple" problem from K&R book. The excercise is as under:
Rewrite the temperature conversion program of Section 1.2 to use a function for conversion.
My attempt:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
float fahr;
float collector;
int lower = 0;
int upper = 300;
int step = 20;
fahr = lower;
while (fahr <= upper)
{
collector = FtoC (fahr);
printf ("\n F is %3.0f & C is %6.1f", fahr, collector);
fahr = fahr + step;
}
return 0;
}
float FtoC (float n)
{
float c;
c = (5.0 / 9.0) * (n - 32.0);
return c;
}
As far as my knowledge goes, there isn't any bug in this code but compiler is returning this error & warning. I've no idea WHY? Kindly help.
/src/celsius_converter.c: In function ‘main’:
../src/celsius_converter.c:23:3: warning: implicit declaration of function ‘FtoC’ [-Wimplicit-function-declaration]
../src/celsius_converter.c: At top level:
../src/celsius_converter.c:30:7: error: conflicting types for ‘FtoC’
../src/celsius_converter.c:23:15: note: previous implicit declaration of ‘FtoC’ was here
make: *** [src/celsius_converter.o] Error 1