C++
Write a program to keep track of the amount of food that one monkey eats in one day. The program should have an array of 24 elements and allow the user to input the amount of food in grams that the monkey eats every hour in a single day so values in a (0.00 to 100.00 range). Once all data has been entered then the program should list the hour that the monkey ate the most plus the average food per hour that the monkey consumed.
#include <iostream>
using namespace std;
int main ()
{
float food[24];
//Read input from user
for(int i=0;i<24;i++){
cin>>food[i];
}
//Find maximum and total
float mx = food[0],total=0;
for(int i=1;i<24;i++){
if(food[i]>mx){
mx = food[i];
}
total = total+food[i];
}
//find avg
float avg = total/24;
cout<<"Maximum food is "<<mx<<" Average food
is "<<avg<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main ()
{
float food[24];
//Read input from user
for(int i=0;i<24;i++){
cin>>food[i];
}
//Find maximum and total
float mx = food[0],total=0;
for(int i=1;i<24;i++){
if(food[i]>mx){
mx = food[i];
}
total = total+food[i];
}
//find avg
float avg = total/24;
cout<<"Maximum food is "<<mx<<" Average food
is "<<avg<<endl;
return 0;
}
OUTPUT :

C++ Write a program to keep track of the amount of food that one monkey eats...