Answer:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int size=100;
float insect_speed [size];
string insect_name [100]={""};
int max=0;
int max_index=0;
for(int i=0;i<size;i++){
cout<<"insect speed"<<endl;
cin>>insect_speed[i];
cin.ignore();
cout<<"insect name"<<endl;
getline(cin,insect_name[i]);
if(insect_speed[i]>max){
max=insect_speed[i];
max_index=i;
}
cout<<"Fastest insect is "<<insect_name[max_index]<<" with speed "<<insect_speed[max_index]<<endl;
}
return 0;
}
Explanation:
Initially took max size of 100. Using string define an string array of size for insect name and float array of size for speeds.
Define a variable max and set to 0 and a max_index and set to 0. max index will store the index of maximum value in array of speed.
For every input of speed check if it greater than max set max to current input vale of speed and max_index to current index of array.
print speed and insect name at max_index for fastest insect.
System will calculate fastest insect at run time an update user after every input.