You are on page 1of 1

Are the arrays identical or not

#include<iostream.h>
main() {
int i;
int A[5]={1,2,3,4,5};
int B[5]={1,2,3,4,5};
for(i=0;i<5;i++)
if(A[i]!=B[i]) break;
if(i==5)
cout<<"The two arrays A and B are identical"<<endl;
else cout<<"The two arrays A and B are not identical"<<endl;
//==========================================
int C[5]={1,2,3,4,5};
int D[5]={1,2,3,4,7};
for(i=0;i<5;i++)
if(C[i]!=D[i]) break;
if(i==5)
cout<<"The two arrays C and D are identical"<<endl;
else cout<<"The two arrays C and D are not identical"<<endl; }
#include<iostream.h>
main() {
int i, tag=0;
int A[5]={1,2,3,4,5};
int B[5]={1,2,3,4,5};
for(i=0;i<5;i++)
if(A[i]!=B[i]) {
cout<<"The two arrays A and B are not identical"<<endl;
tag=1;
break;
}
if(tag==0)
cout<<"The two arrays A and B are identical"<<endl;
//==========================================
int A1[5]={1,2,3,4,5};
int B1[5]={1,2,3,4,1};
for(i=0;i<5;i++)
if(A1[i]!=B1[i]) {
cout<<"The two arrays A1 and B1 are not identical"<<endl;
tag=1;
break;
}
if(tag==0)
cout<<"The two arrays A1 and B1 are identical"<<endl; }

You might also like