Answer to Question #182616 in C++ for zain ul abdeen

Question #182616

Write a program Given two arrays A[n] & B[n] containing bit strings representing sets A & B respectively, write a code fragment to construct bit string representing the set 𝐴 − 𝐵.


1
Expert's answer
2021-04-19T01:40:07-0400
#include<iostream>
#define Max 100


int m,n,i,j,k,p,q,r,s;
int flag=1;
char char1,char2,char3;
void Difference(int *,int *,int ,int);
void Display2(char ,char ,int );


int A[10] = { 1,2,3,4,5,6,7,8,9,0 };
int B[10] = { 1,3,5,7,9 };
int c[10];


void Difference(int *a1,int *b1,int m1,int n1)
{
    q=0;
    p=0;
    i=0;
    for(k=0;k<m1;k++){
        flag=1;
        for(j=0;j<n1;j++){
            if(b1[j]==a1[k]){
                flag=1;
                q++;
                break;
            }
            else{
                flag=0;
            }
        }
        if(flag==0){
            c[p]=a1[k];
            p++;
        }
    }
}


void Display2(char ac,char bc,int m1)
{
    cout<<"The Difference Of Two Sets is :"<<  ac,bc;
    r = m1 - q;
    for(p=0;p<r;p++){
        cout<<c[p];
    }
    cout<<" }";
}




int main(){
    Difference(a,b,m,n);
    Display2('A','B',m);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS