Code:
typedef struct  {   int CourseID;
                    int Prereq1_CourseID;
                    int Prereq2_CourseID;
                } PREREQ;

#define TOTAL 20

//The list of courses and their prerequisites
PREREQ Prereq[TOTAL]={	
    {107,-1,-1},	// The course 107 has no prerequisite.
    {108,-1,-1},	// ...
    {109,-1,-1},
    {117,-1,-1},
    {118,-1,-1},
    {119,-1,-1},
    {127,-1,-1},
    {128,-1,-1},
    {207,107,117},	// To take 207, student must finish either 107 or 117 first
    {209,109,119},
    {218,-1,-1},
    {219,-1,-1},
    {228,108,118},
    {308,-1,-1},
    {309,109,119},
    {318,218,228},
    {319,209,219},
    {407,207,127},
    {408,308,318},
    {409,309,319}};

int GetPositionInArray(int course_id)
{	
	//Description:
	//Given a course ID, find whether its information exists in the Prereq array.
	//If it exists, return its position in the array (ie. 0,1,2,..TOTAL-1).
	//Otherwise return -1

	//Your task: Finish this NON-RECURSIVE function
	int pos;

	for (pos=0; i<TOTAL; i++)
	{	if (course_id == Prereq[pos].CourseID)
			return pos;
		else
			return -1;
	}
	return 0;
}

void main()
{	
	int target1;
	int target2;
	printf("Please enter id of first target course: ");
	scanf("%d",&target1);
	printf("Please enter id of second target course: ");
	scanf("%d",&target2);
	printf("\n");

	//Check whether target1 exists
	{	int PositionInArray;
		PositionInArray=GetPositionInArray(target1);
		if (PositionInArray==-1)
		{	printf("The course id %d is not found.\n",target1);
			exit(0);
		}
		else printf("%d is found as the %dth one in the array.\n",target1,PositionInArray);
	}
When i input course id 407, but output is "The course id 407 is not found. What's wrong about my program, thanks for your help!!