C2371 Error

Hello, I am relatively new to c++ and I need some help figuring out this error code. The error is C2371. The line of code in question is "int cost; " and "double cost; ". What should I do in order to fix the error? Thank you.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{
	
	int cost;
	double cost;
	double area;
	
	double bagSize;
	
	
	

	std::cout << fixed << showpoint << setprecision(2);
	std::cout << "Enter the amount of fertelizer, in pounds,"
		<< "in one bag:";
	std::cin >> bagSize;
	std::cout << endl;

	std::cout << "Enter the area, in square feet, that can be,"
		<< "fertilazed by one bag:";
	std ::cin >> area;
	std::cout << endl;
	std::cout << "The cost of the fertilizer per pound is: $"
		<< bagSize / cost << endl;
	std::cout << "The cost of fertilizing per square foot is: $"
		<< area / cost << endl;
	
	return 0; //End Line
}
You cannot declare two variables with the same name in a function.
1
2
int cost;
double cost;


It also appears that you need to initialize 'cost' with a value. If you don't initialize it, the value will be undefined.
double cost = 25.00; // 25.00$
Topic archived. No new replies allowed.