variable not initialized error... but it has a value??

so, I am writing a program for class that has me asking the user how many people want admission to a theme park, adults cost $50 and kids cost $30, and for a family of 4 or more $150. And I am supposed to output the total cost for them. It is telling me my variable totalCost is not initialized when to me it looks like it is... I made it == 0 at the start of the main function and then I add to it at the bottom but it still tells me it has no value... any help is appreciated!!
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
#include <iostream>;
using namespace std;
int main(void)
{
	// next seven lines are assigning variable names and types.
	int adult;
	int child;
	int family;
	int totalCost;
	int totalCostChild;
	int totalCostAdult;
	totalCost == 0;
	adult == 50;
	child == 30;
	family == 150; // next four ask for user input.
	cout << "How many adults?\n";
	cin >> adult;
	cout << "How many children?\n";
	cin >> child;
		if (child>=4);  // the rest of the code calculates how much it will cost this person, and outputs the total cost.
			cout << "cost is $150";
		if (child<=4);
			(totalCostChild << child*30);
		if (adult>=4);
			cout << "cost is $150";
		if (adult<=4);
			(totalCostAdult << adult*50);
	totalCost + (totalCostAdult + totalCostChild); // Total cost IS INITIALIZED do not know what I am doing wrong here.
	cout << "your price is:" << totalCost;
	return 0;
== is comparison, not assignment. Use = for assignment.
wow, thank you I feel stupid for making that mistake.. it runs now with no errors... gotta fix some other stuff, but thank you very much!
Topic archived. No new replies allowed.