I am doing a module for my programming class where I have to find the lowest and highest temperature and print it and I was going to kind of use a bubble sort but it says "invalid conversion of int* to int" because it is an array.
This is part of the array and the part where I am having problems:
for (k=1;k<8;k++){
cout << "Enter temperature for day " << k << ":";
cin >> temperature[i][k];
cout << "Temperature day " << k <<": "<< temperature[i][k] << endl;
if (k=2)
{ if(temperature[i]>temperature[i-1])
high=temperature[i];
else if (temperature[i]>temperature[i-1])
low=temperature[i];
}
}
This is inside of another array(i) and I am trying to get it to where it finds a low and high temp and then print it! Would really appreciate some help.
I know I am probably doing this in a complicated/not good practice way but I have finals in 2 days and this pretty much the last thing I need to do before it.
I see what you mean and realized my mistake. But now it seems like it is getting stuck at Temperature for day 3. There are no errors in compiling, just when I run the program.
for (k=1;k<8;k++){
cout << "Enter temperature for day " << k << ":";
cin >> temperature[i][k];
cout << "Temperature day " << k <<": "<< temperature[i][k] << endl;
if (k>=2)
{ if(temperature[i][k]>temperature[i][k-1])
high=temperature[i][k];
if (temperature[i][k]<temperature[i][k-1])
low=temperature[i][k];
}
edit: Not sure why but if I changed the last if to an else if, it would not work. Not sure if this is due to putting in an equal value and not having a remaining else statement or what, I just ended up choosing this because it worked.