SUNIL GUTTA

SUNIL GUTTA

  • 1.2k
  • 1k
  • 362.5k

remove errors from this C language code ?

Oct 17 2013 2:06 PM

Hi 


Errors from the code ?? can anyone re-correct it ?


#include <stdio.h>

#include <stdlib.h>


void inputFahrs(double fahr[], int numFahrs);

double fahrToCels(double fahr[]);

void sort(double fahr[], int numFahrs);

void outputFahrs(double fahr[], int numFahrs);

void outputAverage(double fahr[], int numFahrs);

void outputHighLows(double fahr[], int numFahrs);

void outputGrads(double fahr[], int numFahrs);

int main()

{

int numFahrs=0,k,j,m,x,y,z,h,v;

double fahr[25]={0}, sum=0,hold,max,min;

printf("Please enter the number of fahrenheit temperatures to evaluate. From 1-25\n");

scanf("%i", &numFahrs);

while((numFahrs<=1)||(numFahrs>=25));

{

printf("Value entered is out of range, please re-enter value:\n");

scanf("%i",&numFahrs);

}

for(k=0;k<=numFahrs-1;k++)

{

inputFahrs(double fahr[], int numFahrs);

while((fahr[k]<=-175.0)||(data[k]>=175.0));

{

printf("Temperature value is out of range, please re-enter: \n");

scanf("%f", &fahr[k]);

}

sum+= fahr[k];

}

outputFahrs(double fahr[], int numFahrs);

sort(double fahr[], int numFahrs);

outputAverage(double fahr[], int numFahrs);

outputHighLows(double fahr[], int numFahrs);

outputGrads(double fahr[], int numFahrs);

system("PAUSE");

return 0;

}

void inputFahrs(double fahr[], int numFahrs)

{

double fahr[25]={0};

int numFahrs;

printf("Temperature #%i :\n", k+1);

scanf("%f", &fahr[k]);

return;

}

double fahrToCels(double fahr[])

{

return (fahr[k]-32)/1.8;

}

void sort(double fahr[], int numFahrs)

{

int k,j,m;

double hold;

for(k=0;k<=numFahrs-2;k++)

{

m=k;

for(j=k+1;j<=numFahrs-1;j++)

if(fahrs[j]<fahrs[m])

m=j;

hold=x[m];

x[m]=x[k];

x[k]=hold;

}

return;

}

void outputFahrs(double fahr[], int numFahrs)

{

printf("Fahr Cels\n");

printf("===== ======\n");

for(k=0;k<=numFahrs-1;k++)

{

printf("%6.1f %6.1f\n", fahr[k], fahrToCels(fahr[k]));

}

void outputAverage(double fahr[], int numFahrs)

{

avg=sum/numFahrs;

printf("Average %6.1f %6.1f\n", avg, ((avg-32)/1.8));

return;

}

void outputHighLows(double fahr[], int numFahrs)

{

int k;

double max,min;

max=fahr[0];

min=fahr[0]

for (k=0; k<=numFahrs; k++)

{

if(fahr[k]>max)

max=fahr[k];

}

for (k=0; k<=numFahrs; k++)

{

if(fahr[k]<min)

min=fahr[k];

}

printf("High %6.1f %6.1f\n", max, ((max-32)/1.8));

printf("Low %6.1f %6.1f\n", min, ((min-32)/1.8));

return;

}

void outputGrads(double fahr[], int numFahrs)

{

int x=0,y=0,z=0,h=0,v=0;

for(k=0;k<=numFahrs;k++)

{

switch(fahr[k])

{

case (fahr[k]<0.0)

x++;

break;

case ((fahr[k]==0.0)&&(fahr[k]<=32.0))

y++;

break;

case ((fahr[k]>32.0)&&(fahr[k]<68.0))

z++;

break;

case ((fahr[k]>=68.0))&&(fahr[k]<=100.0))

h++;

break;

case (fahr[k]>100.0)

v++;

break;

}

}

printf("Below 0.0 F: %6i\n", x);

printf("Between 0.0 and 32.0 F: %6i\n",y);

printf("Above 32.0 F & below 68.0 F: %6i\n", z);

printf("At least 68.0 F & below 100.0 F: %6i\n", h);

printf("Above 100.0 F: %6i\n", v);

return;

}


Ty


Answers (1)