Write a program that will find how many temperatures were hotter than 22 and how many were colder than 10 (using functions), after that print if there were more hotter or colder temperatures.
but I'm having problems with strings, I'm still not sure if I'm using them properly so if someone could check my errors and help me out in this program I'd be very thankful.
#include <iostream>
usingnamespace std;
int bigger(int s)
{
int b=0;
if(s>22)
{
b=b++;
return b;
}
}
int smaller(int d)
{
int c=0;
if(d<10)
{
c=c++;
return c;
}
}
int main()
{
int i;
int temperatures[10];
for(i=0;i<10;i++)
{
cout<<"Enter the temperatures" <<endl;
cin>>temperatures[i];
}
cout<<"The number of temperatures hotter than 22 is:"<<bigger(temperatures[10])<<endl;
cout<<"The number of temperatures colder than 22 is:"<<smaller(temperatures[10])<<endl;
if(bigger(temperatures)>smaller(temperatures))
cout<<"There were more hotter temperatures"<<endl;
else
cout<<"There were more colder temperatues"<<endl;
return 0;
}
Thank you, however I'm not very good with arrays do you think you could help me out fixing it? I would be very thankful if you can get my mistakes fixed. Thanks
as jezze said you need to loop through your array in your functions. use a similar method to how your reading values into an array on lines 27-31, but get the value out rather than setting it.