Q please explain the following code  (step by step) #include #include using namespace std; int main() {  string country[1000], cty, cty_update;  int i=0,j,choice,max=0;  long tot_pop[1000], infected_pop[1000], recovered_pop[1000];    while(true){            cout<<"1. Enter new records\n";      cout<<"2. Display records\n";      cout<<"3. Check highest infected cases\n";      cout<<"4. Update records\n";      cout<<"5. Exit\n";            cin>>choice;            if(choice==1){          cout<<"Enter country\n";          cin>>country[i];          cout<<"Total Population?\n";          cin>>tot_pop[i];          cout<<"Total Infected?\n";          cin>>infected_pop[i];          cout<<"Total Recovered?\n";          cin>>recovered_pop[i];                    if(infected_pop[i]>max){              max=infected_pop[i];              cty=country[i];          }          i++;      }            if(choice==2){          for(j=0;j>cty_update;          for(j=0;j>infected_pop[j];                  cout<<"Enter new Recovered Population\n";                  cin>>recovered_pop[j];                  break;              }          }      }      if(choice==5)          break;  }    return 0; }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.5: Case Studies
Problem 3E
icon
Related questions
Question
100%

 Q please explain the following code 

(step by step)

#include <iostream>
#include <string>
using namespace std;

int main() {
 string country[1000], cty, cty_update;
 int i=0,j,choice,max=0;
 long tot_pop[1000], infected_pop[1000], recovered_pop[1000];
 
 while(true){
     
     cout<<"1. Enter new records\n";
     cout<<"2. Display records\n";
     cout<<"3. Check highest infected cases\n";
     cout<<"4. Update records\n";
     cout<<"5. Exit\n";
     
     cin>>choice;
     
     if(choice==1){
         cout<<"Enter country\n";
         cin>>country[i];
         cout<<"Total Population?\n";
         cin>>tot_pop[i];
         cout<<"Total Infected?\n";
         cin>>infected_pop[i];
         cout<<"Total Recovered?\n";
         cin>>recovered_pop[i];
         
         if(infected_pop[i]>max){
             max=infected_pop[i];
             cty=country[i];
         }
         i++;
     }
     
     if(choice==2){
         for(j=0;j<i;j++){
             cout<<"Country = "<<country[j]<<endl;
             cout<<"Total Population = "<<tot_pop[j]<<endl;
             cout<<"Infected Population = "<<infected_pop[j]<<endl;
             cout<<"Recovered Population = "<<recovered_pop[j]<<endl;
             cout<<endl;
         }
     }
     if(choice==3){
         cout<<"\nCountry with highest infections is "<<cty<<" with number of infections = "<<max<<endl;
     }
     if(choice==4){
         cout<<"Enter the country to update\n";
         cin>>cty_update;
         for(j=0;j<i;j++){
             if(cty_update.compare(country[j])==0){
                 cout<<"Enter new infected Population\n";
                 cin>>infected_pop[j];
                 cout<<"Enter new Recovered Population\n";
                 cin>>recovered_pop[j];
                 break;
             }
         }
     }
     if(choice==5)
         break;
 }
 
 return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr