Your CONSOLE program must accept positive integer numbers as elements for two different SETS. Given with choices, you will perform union, intersection, and difference of the sets based on the input of the user, based on the following example:
Enter elements for Set A: (0 to end entering)
First Set: 1
First Set: 5
First Set: 8
First Set: 2
First Set: 0
A= {1, 5, 8, 2}
Enter elements for Set B: (0 to end entering)
Second Set: 6
Second Set: 2
Second Set: 0
B= {6, 2}
Choices:
A: Union of sets A and B
B: Intersection of sets A and B
C: A-B
D: Exit
Choose operation: A
Union of A and B={1, 5, 8, 2, 6}
Choose operation: B
Intersection of A and B={2}
Choose operation: C
A-B={1, 5, 8}
Choose operation: D
//end of program
here's my code but i dont know what to already..help pls..
#include<iostream>
using namespace std;
int main(){
char choice;
int x, ctr1st=0,ar;
int set1[]={};
int set2[]={};
cout<<"Enter elements for SET A:"<<"\n";
do{
cout<<"First set:";
cin>>set1[x];
}
while(set1[x]!=0);
cout<<"\n\n";
cout<<"Enter elements for SET B: "<<endl;
do{
cout<<"Second set: ";
cin>>set2[x];
}
while(set2[x]!=0);
cout<<"\n\n";
cout<<"Choices:"<<endl;
cout<<"A: Union of sets A and B"<<endl;
cout<<"B: Intersection of sets A and B"<<endl;
cout<<"C: A-B"<<endl;
cout<<"D: Exit"<<endl;
cout<<"What do you want to do? "<<"Please enter your choice:";cin>>choice;
switch(choice){
case 'A':
case 'a':
if(set1[x]==set2[x]){
cout<<"Union of A and B ="<<"{"<<set1[x]<<","<<set2[x]<<"}"<<endl;}
break;
case 'B':
case 'b':
cout<<"Intersection of A and B ="<<"{"<<"}"<<endl;
break;
case 'C':
case 'c':
cout<<" A - B ="<<"{"<<"}"<<endl;
break;
case 'D':
case 'd':