Find and correct six errors in the program. The errors can be both syntax and lo
ID: 3566380 • Letter: F
Question
Find and correct six errors in the program.
The errors can be both syntax and logical
// This program predicts the population size of the organisms // by the initial population, the value of increase, and the // number of days the population is observed #include using namespace std; int main() { int number, increase, days; cout << "Enter the starting number of organisms" << endl; cin >> number; cout << "Enter the average daily increase (in %)" << endl; cin >> increase; cout << "Enter the number of days" << endl; cin >> days; populationSize(startingNumber,DailyIncrease,numberOfDays); //This function should display the number of organisms on each day void populationSize(int startingNumber, int dailyIncrease, int numberOfDays); { int count=startingNumber; for (int i=1;i<=numberOfDays) { count+=dailyIncrease*count/100; } cout << "On day " << i << " there will be " << count << " organisms" << endl; } }
Explanation / Answer
#include <stdio.h>
#include<iostream.h>
//using namespace std;
//populationSize(startingNumber,DailyIncrease,numberOfDays);
int main()
{
int number, increase, days;
cout << "Enter the starting number of organisms" << endl;
cin >> number;
cout << "Enter the average daily increase (in %)" << endl;
cin >> increase;
cout << "Enter the number of days" << endl;
cin >> days;
//populationSize(startingNumber,DailyIncrease,numberOfDays);
//This function should display the number of organisms on each day
void populationSize(int startingNumber, int dailyIncrease, int numberOfDays);
{
int startingNumber,numberOfDays,dailyIncrease;
int count=startingNumber;
for (int i=1;i<=numberOfDays;i++)
{
count+=dailyIncrease*count/100;
}
cout << "On day " << i << " there will be " << count << " organisms" << endl;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.