Respuesta :
Answer:
The solution code is written in c++
- #include <iostream>
- using namespace std;
- struct Frog {
- string Name;
- int Age;
- float LegLength;
- };
- int main ()
- {
- Frog frog_test;
- frog_test.Name = "Todd Jones";
- frog_test.Age = 12;
- frog_test.LegLength = 12.34;
- int num;
- cout<<"Enter number of frogs: ";
- cin>>num;
- Frog frog[num];
- int i;
- for(i = 0; i < num; i++){
- cout<<"What is the name of Frog "<< i + 1 <<" ?";
- cin>> frog[i].Name;
- cout<<"What is the age of Frog "<< i + 1 <<" ?";
- cin>> frog[i].Age;
- cout<<"What is the leg length of Frog "<< i + 1 <<" ?";
- cin>> frog[i].LegLength;
- }
- }
Explanation:
Firstly, define a Frog struct as required by the question (Line 4 - 8).
We create a test Frog struct (Line 12 - 15).
If we run the code up to this point, we shall see a Frog struct has been build without error.
Next, prompt user to input number of frogs desired (Line 17 -19).
Use the input number to declare a frog array (Line 21).
Next, we can use a for loop to repeatedly ask for input info of each frog in the array (Line 23- 34).
At last, we shall create num elements of Frog struct in the array.