NEED HELP!!!

Hey can't find out why this in incrementing wrong. It should increment the function check answers 128 time, however it is only incrementing it about 50-60 times and idk why that is.


Here is the code

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
for(int x=0;x<2;x++){
			for(int y=0;y<4;y++){
				for(int z=0;z<16;z++)
				{
					if(kids[x][y][z].getSN()==0){
						kids[x][y][z].checkAnswers(tempA);						
						kids[x][y][z].getCorrect(tempE);
						A[0].findCorrect(tempE);
						kids[x][y][z].checkGrade();
						if(x=0)
							A[0].correctSecOne(tempE);
						if(x=1)
							A[0].correctSecTwo(tempE);
						for(int g=0;g<100;g++)
							tempKids[x][y][z][g]=tempE[g];
					}
					if(kids[x][y][z].getSN()==1){
						kids[x][y][z].checkAnswers(tempB);
						kids[x][y][z].getCorrect(tempE);
						A[1].findCorrect(tempE);
						kids[x][y][z].checkGrade();
						if(x=0)
							A[1].correctSecOne(tempE);
						if(x=1)
							A[1].correctSecTwo(tempE);
						for(int g=0;g<100;g++)
							tempKids[x][y][z][g]=tempE[g];
					}
					if(kids[x][y][z].getSN()==2){
						kids[x][y][z].checkAnswers(tempC);
						kids[x][y][z].getCorrect(tempE);
						A[2].findCorrect(tempE);
						kids[x][y][z].checkGrade();
						if(x=0)
							A[2].correctSecOne(tempE);
						if(x=1)
							A[2].correctSecTwo(tempE);
						for(int g=0;g<100;g++)
							tempKids[x][y][z][g]=tempE[g];
					}
					if(kids[x][y][z].getSN()==3){
						kids[x][y][z].checkAnswers(tempD);
						kids[x][y][z].getCorrect(tempE);
						A[3].findCorrect(tempE);
						kids[x][y][z].checkGrade();
						if(x=0)
							A[3].correctSecOne(tempE);
						if(x=1)
							A[3].correctSecTwo(tempE);
						for(int g=0;g<100;g++)
							tempKids[x][y][z][g]=tempE[g];
					}
					}
				}
				}


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
void Students::checkAnswers(const int a[100][2]){
	//Variable to hold the test answers
	/*int theKey[100][2];

	for(int i=0;i<100;i++)
		{
			theKey[i][0] = a[i][0];
			theKey[i][1] = a[i][1];
		}	
	*/
	//checks students answers to key
	ofstream output;
	output.open("Check Answers output.txt",ios::app);
	for(int i=0;i<100;i++)//NOT !!!  WORKINGGGGG
	{
		if(answers[i]==a[i][0]||answers[i]==a[i][1])
		{
			totalCorrect[i]=1;
		}
		else
		{
			totalCorrect[i]=0;
		}
		output<<totalCorrect[i]<<endl;
	}
	output<<"///////"<<endl;
	output.close();
	
	
	
}
Last edited on
You should edit that block of crap so that the closing code blocks look like: [ / code ]
Aight did that, forgot it was the other way around.
You code in frustration comments the same way my brother does.

How many times exactly does it increment? 64?
Yea 65 times do you know why that is?
Last edited on
I feel like I'm missing something. It's ignoring the second iteration of x, but I don't know why. What's the scope of the three for() loops that you posted? And can I see the next higher level of code?
These are links to the entire project its 5 classes w/ header files and a main function however i am pretty sure the problem lies in that brick of code above

http://pastebin.com/En1c0ycZ
http://pastebin.com/JEVcDxxz
http://pastebin.com/FjXSq74f
http://pastebin.com/E5UqDncY
http://pastebin.com/ZkYpb768
http://pastebin.com/YReyUpQW
http://pastebin.com/148jXppg
http://pastebin.com/PMbEnmYP
http://pastebin.com/eXWzUpTE
You have assignment operators in your ifs

1
2
if(x=0)  // assigns x the value 0
if(x=1)  // assigns x the value 1 


This messing with the loop control variables is probably the cause of the problem
Last edited on
Topic archived. No new replies allowed.