1

I am using TurboC. What's wrong with this code? During the runtime, the message was "floating point formats not linked" "Abnormal program termination". I am a newbie in C language, and I've never encountered this kind of error before. Thanks in advance!

/* averages arbitrary number of temperatures */
/* uses pointer notation */
main()
{
     float temper[40];                                  /* Array declaration */
     float sum=0.0;
     int num, day=0;

     do                                                 /* Puts temps in array */
     {
         printf("Enter temperature for day %d: ", day);
         scanf("%f", temper+day);
     }
     while( *(temper+day++) > 0 );

     num = day-1;                                       /* number of temps entered */
     for(day=0; day<num; day++)                         /* calculate average */
          sum += *(temper+day);
     printf("Average is %.1f", sum/num);

     getche();
}
Aaron
  • 1,969
  • 6
  • 27
  • 47

2 Answers2

2

Please see this FAQ: Turbo C program which crashes and says something like "floating point formats not linked."

The solution they suggest is to add a dummy call to the sqrt function so that the compiler/linker detects that you need floating point support linked in. I would expect there to also be an option for your compiler and/or IDE that you could set instead, but I don't know anything about about Turbo C.

David Grayson
  • 84,103
  • 24
  • 152
  • 189
1

You need to enable linking floating point library in TurboC, from options>linkers>library>floating point.

farhanhubble
  • 476
  • 3
  • 18
  • **Option>Linker>** Map file | Initialize segments | Default libraries | Graphics library | Warn Duplicate symbols | Stack warning | Case-sensitive link. *Which one?* – Aaron Jun 03 '11 at 05:32
  • @aerohn It's been a long time since I used TC, but it should probably be in default libraries. – farhanhubble Jun 03 '11 at 06:18