This is one part of my program, I need a loop that checks through the input(specifically the agent numbers) and then outputs the agent numbers that aren't in the input, from 1 to 20(because there should only be 20 agent).

void not_part()
{
	ins.open(in_file);
	int i=0;
	int sum=0;
	cout<<"AGENTS WHO DID NOT PARTICIPATE IN THE CAMPAIGN"<<endl;
	cout<<fixed<<showpoint;
	cout<<setprecision(2);
	while(!ins.eof())
	{
		ins>>agent[i]>>sales[i]>>value[i];
		amount[i]=sales[i]*value[i];
		for(int j=1; j<=20; j++)
		{
			for(int t=0; t<=count; t++)
			if(j!=agent[t])
			{
				sum+=1;
				if(sum==count)
				{
					cout<<j<<" ";
					sum=0;
				}
			}
		
		}
		
		i++;
	}
		
	cout<<endl;
	ins.clear();
	ins.close();
}

My input is :
1 3 250.00
2 0 0
15 1 1000.00
3 4 300.00
12 2 500.00
1 2 300.00
3 4 115.00
21 3 400.00
-1 4 250.00
15 1 200.00
9 5 -150.00
18 2 140.00
13 2 550.00
I know my loop is wrong, I need help to correct it.

So what does your output mean? What's wrong with it? Just posting a bunch of numbers with no explanation makes it impossible to help.

The output is the numbers from 1 to 20 that are not in the input, they are the agent who did not participate, the loop has something wrong with it, it should check through the input and if the number isn't there then it should output it

Those numbers look fine to me based on the data you've supplied.

But it doesn't work, so what wrong with it???

I came up with this to now, but it also doesn't work

void not_part()
{
	ins.open(in_file);
	int there[20];
	cout<<"AGENTS WHO DID NOT PARTICIPATE IN THE CAMPAIGN"<<endl;
	cout<<fixed<<showpoint;
	cout<<setprecision(2);
	while(!ins.eof())
	{
		int agnt, sals;
		float val;
		ins>>agnt>>sals>>val;
		if((agnt>0)&&(agnt<21)&&(value>=0))
			there[agnt]=1;

		for(int i=1; i<20; i++)
		{
			if(there[i]==0)
				cout<<i<<" ";
		}
	}
	cout<<endl;
	ins.clear();
	ins.close();
}

ok well i used arrays and got it working after like 3 days of no assistance from daniweb!

That's because you refused to give us the information necessary to know what was going on. We had no input to understand what you were testing with, so how could we possibly know what numbers were in error. You didn't even bother to tell us what was wrong with the output -- just that it was wrong. So don't blame us for your lack of info. We asked for it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.