I'm trying to get the hang of calling functions correctly and everything. But when I compile this, it gives me "undeclared identifers" errors for the variables in the functions. But I've identified them in main. What am I doing wrong???
Code:#include <iostream> using namespace std; double growthRate(double); int estimatedPopulation(double); int main() { int P; double B; double D; int n; double sub; double total; cout << "Enter current population: "; cin >> P; if (P < 2) { cout << "Current population must be greater than 2"; cout << "\nEnter current population: "; cin >> P; } cout << endl; cout << "Enter birth rate: "; cin >> B; if (B < 0) { cout << "Birth rate must be greater than or equal to 0"; cout << "\nEnter birth rate: "; cin >> B; } cout << endl; cout << "Enter death rate: "; cin >> D; if (D < 0) { cout << "Death rate must be greater than or equal to 0"; cout << "\nEnter death rate: "; cin >> D; } cout << endl; cout << "Enter the number of years for the projected population: "; cin >> n; cout << endl; cout << "Growth rate = " << growthRate(sub) << " %" << endl; cout << "Projected population after " << n << " years = "; cout << estimatedPopulation(total) << endl; return 0; } double growthRate(double sub) { sub = B - D; return sub; } int estimatedPopulation(double total) { total = n * (P + ((P / 100) * growthRate(sub))); return total; }