0

Hi,
I am very new to this forum and i have a problem with my C assignment. Im using Borland C++ 4.52 and i keep getting an error saying:

General Protection Exception
0x241F:0X41C1
NONAME02(1)0X241F:0X41C1 Processor Fault

It not the computer its the code at least thats what i figured because i tried the same code on 6 pc and the same error pops up.

I will attach the code so that you can have a better understanding of my problem.

Attachments
#include <stdio.h>
float findmaxtemp(float[]);
float minimumtemp(float);//float[]
void gettemps(float temp[]);
void display(float);
int main()
{
 float temp[10];
 float answer=0.00;
 float a;
 gettemps(temp);
 answer=findmaxtemp(temp);
 a=minimumtemp(answer);//temp
 display(a);
  return 0;
}
float findmaxtemp(float temp[])
{
 float value;
 value=temp[0];
 for (int i=1; i <=10;i++)
 {
  if (value < temp[i])
  value=temp[i];
 }
 return value;
}
float minimumtemp(float temp)//float temp_array
{
 float dew_point;
 float nextday_maximumtemperature;
 float maxtemp;
  printf("\n Please enter a dew point readings");
  scanf("%f",&dew_point);
  if(dew_point > 26 || dew_point < 19)
  {
  printf("\n ERROR");
  printf("\n Please enter a dew point reading");
  scanf("%f", &dew_point);
  }
 maxtemp=temp;
 nextday_maximumtemperature=((maxtemp + dew_point)/2.0)+0.35;
 return nextday_maximumtemperature;
}
void gettemps(float temp[])
{
 printf("\n Please enter ten temperature ");
 for(int i=0; i<10;i++)
  {
 scanf("%f",temp[i]);
  }
}
void display(float nextday_maximumtemperature)
{
  printf("\n %2.f", nextday_maximumtemperature);
}
2
Contributors
2
Replies
3
Views
13 Years
Discussion Span
Last Post by bajanstar
0

Greetings,

A simple fix I saw. In your function gettemps() change:

scanf("%f",temp[i]);

To"

scanf("%f",[b]&[/b]temp[i]);

if If you want to store the result of a scanf operation on a standard variable you should precede it with the reference operator, i.e. an ampersand sign (&).


- Stack Overflow

0

hi,
I didnt even notice that :) thanks for your help i really appreciate it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.