This is my instructions
and i am using Dev-C++ 4.9.9.2
and i am using the Mingw compiler
i am a beginner.
and this is my code.
#include <iostream>
#include <iomanip>
using namespace std;
void everything();
int main()
{
everything();
system("pause");
return 0;
}
void everything()
{
int a,b,k,sum;
bool flag;
cout<<"Please enter the amount of students taking COSC 208"<<endl;
cin>>a;
int cosc208[a];
int Intersection[a];
cout<<"Please enter the ID's for all the students who are taking COSC 208 and press enter"<<endl;
for (int i=0; i<a; i++)
cin>>cosc208[i];
cout<<"Please enter the amount of studnts whose major is CTEC."<<endl;
cin>>b;
int CTECstudents[b];
cout<<"Please enter the ID's for all the students with CTEC as thier major."<<endl;
for (int i=0; i<b; i++)
cin>>CTECstudents[i];
for(int i=0;i<a; i++)
{
flag==false;
for(int j=0;j<b; j++)
{
if(cosc208[i]==CTECstudents[j])
flag==true;
if (flag==true)
{
Intersection[k]=cosc208[i];
sum=k++;
}
cout<<sum<<endl;
}
}
int i=0;
while(i<k)
{
cout<<"The CTEC students taking COSC 208 are: "<<Intersection[i]<<endl;
i++;
}
}
i just can't get the intersection array to cout right