Моя программа потерпела крах, прежде чем что-либо было выполнено, за исключением заявлений printf()
. Я также пытаюсь включить функцию определения пользователя, но я делаю что-то неправильно, потому что это дало мне ошибку, что она была неопределенной, у меня было это выше int main()
, но она по-прежнему отмечена той же ошибкой. Мне нужны случайные числа для заполнения массива.Запуская массив со случайными числами/ошибкой с пользовательской функцией
#include <stdio.h>
#include <stdlib.h>
#define ARR SIZE 25
#define MAXIMUM 100
#define MINIMUM 60
int main()
{
int temp_sum; //Initializes sum of all temperatures in order to calculate average total.
int temp_min, temp_max; //Initializes minimum and maximum temperature variables.
int hour_count; //Initializes actual hour of the day.
int temperature[25]; //Initializes array to have 25 elements.
int x, maximum, minimum;
float temp_avg; //Sets variable to accept a decimal.
hour_count=0;
printf("Temperature Conditions on October 9th, 2015:\n");
printf("Time of Day \t \t Temperature in Degree Farenheit\n");
//Starts for loop to add one to each hour of the day.
for (hour_count=0; hour_count<=24; hour_count++)
{
if (temperature[x]>maximum)
{
temp_max=temperature[x];
temp_max=x;
}
if (temperature[x]<minimum)
{
temp_min=temperature[x];
temp_min=x;
}
printf("%d \t\t\t %d\n", hour_count, temperature);
}
temp_sum=0;
for (x=0; x<=24; x++)
{
temp_sum=temp_sum+temperature[x];
}
temp_avg=temp_sum/25;
void GetValue(int value[], int x)
{
value[x] = (rand()%(100-60+1))+60;
}
printf("The maximum temperature for the day is %d degrees Farenheit.\n", temp_max);
printf("The minimum temperature for the day is %d degrees Farenheit.\n", temp_min);
printf("The average temperature for the day is %d degrees Farenheit.\n", temp_avg);
return 0;
}
Проверьте свой окончательный 'ptintf': какую температуру вы хотите распечатать? –
ПОЖАЛУЙСТА, не меняйте вопрос, как только вы получите ответ. Вы всегда можете [изменить] на ___add___ более подробную информацию. Спасибо –