for loop error?

the first loop is employee number 1. after i have input the relevant data, the next employee number is 7? can someone tell me why the for loop skip 2-6?
THANK YOU SO MUCH
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
	do
	{
		cout<<"Please enter the number of employee you wish to create = ";
		cin>>NumberOfEmployee;
		cin.ignore(5,'\n');

		if (NumberOfEmployee > 20)
		{
			cout<<"Maximum 20 Employees for each department.\n"
				<<endl;
		}

	}while(NumberOfEmployee>20);

	for(i = 1; i<=NumberOfEmployee;i++)
	{

		cout<<"Employee Number "<<i
			<<endl;
		do
		{
			again = false;		
			cout<<"Please enter the Employee's ID = ";		
			cin.getline(temp,80 ,'\n');
		
			if(strlen(temp)!=6)		
			{				
				cout<<"The length of Employee ID must be 6 characters.\n"				
					<<endl;
		
				again = true;		
			}		
			if(temp[0]<'A' || temp[0]>'Z')		
			{					
				cout<<"The first character of the Employee ID must be a uppercase letter.\n"				
				<<endl;		
			
				again = true;		
			}		
			for(i=1; i<=5;i++)		
			{			
				if(!isdigit(temp[i]))			
				{				
					//system("cls");				
					cout<<"The last 5 characters of the Employee ID must all be in digits.\n"					
						<<endl;				
					again = true;				
					break;			
				}		
			}	
		}while(again);	
		strcpy(EmployeeID,temp);
	
		do
		{
			again = false;
		
			cout<<"Please enter the name of the Employee = ";		
			cin.getline(temp,80,'\n');
		
			if(strlen(temp)>20)		
			{			
				//system("cls");			
				cout<<"Employee's name must be at most 20 characters.\n"				
					<<endl;			
				again = true;		
			}	
		}while(again);	
		strcpy(Name,temp);

	
		do	
		{		
			again = false;		
			cout<<"Please enter the Employee's telephone number = ";
			cin.getline(temp,80,'\n');
		
			if(strlen(temp)!=7)
			{
			
				//system("cls");			
				cout<<"Telephone number must be at 7 digits.\n"				
					<<endl;			
				again = true;		
			}
	
		}while(again);	
		strcpy(TelephoneNumber,temp);

		do
		{		
			again = false;		
			cout<<"Is the employee salaried employee(S) or an hourly paid employee(H) = ";		
			cin>>EmployeeType;
			cin.ignore(5,'\n');
		
			if(EmployeeType !='H'&& EmployeeType !='S')
			{
				cout<<"Please enter either [S] for salaried employee or [H] for hourly paid employee.\n"
					<<endl;
				again = true;
			}
		}while(again==true);

		cout<<setiosflags(ios::left)<<setw(7)<<EmployeeID
			<<setw(21)<<Name
			<<resetiosflags(ios::left)<<setw(8)<<TelephoneNumber
			<<setw(2)<<EmployeeType
			<<endl;
		
		outfile<<setiosflags(ios::left)<<setw(7)<<EmployeeID
			<<setw(21)<<Name
			<<resetiosflags(ios::left)<<setw(8)<<TelephoneNumber
			<<setw(2)<<EmployeeType
			<<endl;

		cout<<endl;
		system("pause");
		system("cls");
		
	}
Last edited on
for(i = 1; i<=NumberOfEmployee;i++) for(i=1; i<=5;i++)

I believe it'd be because you are using the same variable for two loops.

Starts at 1 at first loop. When it gets to second loop it goes to 1 again and increments to 6 then it returns to first loop and adds one more to become 7.
I got it now. Thanks a lot!
Topic archived. No new replies allowed.