Arrray/loops

I have compiled this code, it compiles and runs, but it runs a blank program. Im not sure what could cause this.

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 <cstdlib>
#include <iostream>
using namespace std;

int main()
{
    double salary[6];
	for (int i = 0; i < 6; i = 1+1)
	{
		salary[i] = 0.0;
	}
	
	cout << "You will be asked to enter the salary for 6 workers."<< endl;
	for (int i = 0; i < 6; i = i+1)
	{
		cout << "Enter salary for a worker: ";
		cin >> salary[i];
	}

	cout << endl;
	cout << "The salaries you entered are: "<< endl;
	for (int i = 0; i < 6; i = i+1)
	{
		cout << salary[i] << endl;
	}
	system("pause"); 
	return 0;
}
Because of line 9:

for (int i = 0; i < 6; i = 1+1) // Note: one + one
1
2
3
4
5
6
7
// i = 1+ 1 always equals to 2 so it is stuck in a infinite loop.

// replace it with 
for (int i = 0; i < 6; i++)
	{
		salary[i] = 0.0;
	}
Thanks! Missed that typo!
Topic archived. No new replies allowed.