Write code to compare two arrays if they contain the same elements
Click for Solution

  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
    A flag=0;
    for(int i=0;i<n;i ){
    for(int j=0;j<n;j )
    {if(a[i]!=b[j]){flag=1;break;}}
    }
    if(flag==1)
    cout<<"different arrays";
    else
    cout<<"identical arrays";


  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
    A why the whole code is not displaying?


  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
    A #include<stdio.h>
    void main()
    {
    int i,j;
    int a[]={1,2,3,4};
    int b[]={1,2,3,4};
    int flag=0;
    for(i=1;i<4;i )
    {
    printf("%d ",a[i-1]);
    }
    printf("\n");
    for(i=1;i<4;i )
    {
    printf("%d ",b[i-1]);
    }

    for(i=0,j=0;i<3


  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 681
    A [code]
    #include<stdio.h>
    void main()
    {
    int i,j;
    int a[]={1,2,3,4};
    int b[]={1,2,3,4};
    int flag=0;
    for(i=1;i<4;i )
    {
    printf("%d ",a[i-1]);
    }
    printf("\n");
    for(i=1;i<4;i )
    {
    printf("%d ",b[i-1]);
    }

    for(i=0,j=0;i<3


  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 664

  • Warning: Illegal string offset 'name' in /home/prepdo6/gpl4you/discussquessub.php on line 682
    S
    flag=0;
    for(int i=0;i<n;i  ){
    for(int j=0;j<n;j  )
    {if(a[i]==b[j]){flag=1;}
    if(flag!=1)
    {flag=100;cout<<"different arrays";break;}
    }
    if(flag==1)
    cout<<"identical arrays";
    
    
    


[Insert Code]