function hot_days(), that has two parameters: the number of temperatures for the current month and an array in which the temperatures are stored. Search through the temp array and count all the days on which the noon temp exceeds 32. Return this count.
check my hot_days function in the end of the code. the icounter is not working and i think the problem is in the x < 32.
#include <stdio.h>
#include <conio.h>
#define HIGH 32
//function prototypes
void read_temps(int []);
void hot_days(int [], int []);
int main()
{
//Array
int TempsAry[31];
int hotAry[31];
//sending array
read_temps(TempsAry);
//sending hot array
hot_days(TempsAry, hotAry);
getch();
return 0;
}
void read_temps(int TempsAry [])
{
// variables
int tempnum ;
int x = 0 ;
int icount = 0;
while (x < 31)
{
// entering temperature
printf("Please enter today's temperature:\n ");
scanf("%d",&tempnum);
if (tempnum <= -500)
{
break;
}
TempsAry[x] = tempnum;
++x;
icount = icount +1;
}
//outputting array
for (x = 0 ; x<icount; ++x)
{
printf("%d\n",TempsAry[x]);
}
}
void hot_days(int TempsAry [], int hotAry [])
{
int x = 0 ;
int icount = 0;
while (x<31)
{
if (TempsAry[x] > HIGH)
{
hotAry[x] = TempsAry[x];
++icount;
}
++x;
}
printf("%d\n", icount);
}