Q1
Q1
//if the temperature[i][j] is >= 27 then assign the value 'H' instead
of element//
if(*(*(temperature+i)+j)>=27)
{
new_array [j*d + i]='H';
}
//if the temperature is >=23 and <27 then assign 'M'
else if(*(*(temperature+i)+j)>=23 && *(*(temperature+i)+j)<27 )
{
new_array[j*d + i]='M';
}
//else assigning 'L'
else
{
new_array[j*d + i]='L';
}
}
}
//printing the new_array
for(i = 0; i < d; i++)
{
for(j = 0; j < h; j++)
{
cout<<"["<<i<<"]"<<"["<<j<<"]"<<" = "<<new_array[j*d + i]<<"\t\t";
}
cout<<"\n";
}
//deleting the new_array allotted space
delete[] new_array;
cout<<"\n";
}
//this is to print the highest temperature from each hour per day
void highesthourEach(float temperature[][100], int d, int h)
{
int i, j;
float highesthourEach;
for(i = 0; i < h; i++)
{
//assigning the min value to the highesthourEach
highesthourEach=-999999999999999999999999999999999999;
for(j = 0; j < d; j++)
{
//if the present value is greater than the highesthourEach , then
change the highesthourEach to present value
if(highesthourEach<(*(*(temperature+j)+i)))
{
//changing the highesthourEach
highesthourEach=*(*(temperature+j)+i);
}
}
//printing the highest temperature of the hour per day
cout<<"highest"<<" = "<<highesthourEach<<"\t\t";
}
cout<<"\n";
}
//to display the data in temperature array
void display(float temperature[][100], int d, int h)
{
//i and j is to traverse through array
int i, j;
//loop through rows
for(i = 0; i < d; i++)
{
//loop through columns
for(j = 0; j < h; j++)
{
cout<<"["<<i<<"]"<<"["<<j<<"]"<<" = "<<*(*(temperature+i)+j)<<"\t\t";
}
cout<<"\n";
}
}
int main()
{
//declaring the temperature array
float temperature[100][100];
//h and d is taking the no of hours and days respectively
double h, d;
for(i=0;i<d;i++)
{
for(j=0;j<h;j++)
{
cin>>temperature[i][j];
}
}
cout<<"\n";
//displaying and calling the display Function
cout<<"The displayed temperature data is:"<<endl;
display(temperature,d,h);
//showing HLMTemp
cout<<"\nThe Found \"H\" \"M\" and \"L\" temperature is:"<<endl;
HLMTemp(temperature,d,h);
return 0;
}