Publicité
Please code the following in c++ language- create a program that reads.docx
Please code the following in c++ language- create a program that reads.docx
Prochain SlideShare
Sample Program file class 11.pdfSample Program file class 11.pdf
Chargement dans ... 3
1 sur 2
Publicité

Contenu connexe

Plus de ellenj4(20)

Publicité

Please code the following in c++ language- create a program that reads.docx

  1. Please code the following in c++ language. create a program that reads in the population of five districts into an array, and the growth rate of each district. then apply the growth rate to the population and print the new population sizes and total population. Solution #include<iostream> using namespace std; int main() { int population[5],growthRate[5],totalpop=0; for(int i=0;i<5;i++) { cout<<" Enter Population for District "<<i+1<<": "; cin>>population[i]; cout<<" Enter Growth Rate for District "<<i+1<<": "; cin>>growthRate[i]; } cout<<" "; for(int i=0;i<5;i++) { totalpop+=population[i]*growthRate[i]; cout<<" New Population for District "<<i+1<<" is: "<<population[i]*growthRate[i]; } cout<<" Total Population = "<<totalpop; return 0; } output: Enter Population for District 1: 10
  2. Enter Growth Rate for District 1: 2 Enter Population for District 2: 20 Enter Growth Rate for District 2: 2 Enter Population for District 3: 30 Enter Growth Rate for District 3: 3 Enter Population for District 4: 40 Enter Growth Rate for District 4: 2 Enter Population for District 5: 50 Enter Growth Rate for District 5: 2 New Population for District 1 is: 20 New Population for District 2 is: 40 New Population for District 3 is: 90 New Population for District 4 is: 80 New Population for District 5 is: 100 Total Population = 330 RUN SUCCESSFUL (total time: 54s)
Publicité