Okay before I begin let me make this disclaimer: I'm a complete noob at programming and just started C a month ago so please don't let my ignorance irritate you.
Okay, I'm writing a program that asks a user to enter any random temperatures 26 times until the control loop variable is met. Once it is the program returns a printf that displays the avg. temp and the number of cold, hot, and warm days according to range of 60-=cold, 60-84= warm, and 85+=hot.
Now with what I have so far I believe I have everything to get the avg. part calculated but when I go to compile I get 2 undefined reference errors for the functions "get_value", and "calculate_and_print". But aren't these syntactically correct functions?
And if someone can be so kind to just summarize how I should go about writing the portion to calculate and return the number of hot, cold, and warm days I really appreciate it. I'm not looking for someone to write it, but merely to provide me with some instructions I can understand unlike my text. Below is what have so far and thanks for any and all insight! .............
Code:
/* A program to collect, calculate, and return the daily average of hot,
pleasant, and cold days
Written by: Bryan Jones
Febuary 22, 2008
*/
#include <stdio.h>
int get_n(void);
void calculate_and_print(int n);
double get_value(void);
int main(void)
{ int n;
n=get_n();
calculate_and_print(n);
return 0;
}
int get_n(void)
{
int n;
printf("What is the total of numbers to be entered?");
scanf("%d", &n);
return n;
}
void calculate(int n)
{
double sum, average;
int i;
sum=0.0;
for (i=1; i<=n; i++)
sum=sum+get_value();
average=sum/(double)(n);
printf("The average temperature is %lf\n\n",n, average);
return;
}