i have an assignment can somebody help me,

Assignment Statement: Comparing two arrays for equality or matching indexes

You are required to write a program which will take input from user in two integer arrays. The program should compare both arrays for checking if both arrays are totally identical (Exactly same). If not, then program should determine the matching indexes of both arrays. Matching indexes means that first element of array1 should be equal to first element of array2 and so on.

Recommended Answers

All 6 Replies

Try to write the code out and see if you get the answer. This is simpler than you think. If you really can't get it, post your code (make sure you use code blocks) and we will give you some code/advice.

-Sam

If this is the biggest problem of your life, you are truly blessed.

commented: LOL! :) +4

haha, yea I agree. "please help me i having biggest problem of my life;" is pretty dramatic.

Not until you help yourself. Show us your attempt first.

i attempt this code but it doesn't run, plz help me
#include<iostream.h>
#include<conio.h>
void match(int a[10],int b[10]);
void main()
{
int x[10],y[10],m,n;
clrscr();
cout<<"Enter elements of 1st array:"<<endl;
for(m=1;m<11;m++)
{
cout<<"element "<<m<<" is =";
cin>>x[m];
}
cout<<"Enter elements of 2nd array:"<<endl;
for(n=1;n<11;n++)
{
cout<<"element "<<n<<" is =";
cin>>y[n];
}
match (x,y);
getch();
}
void match(int a[10], int b[10])
{
int i,j;
{
cout<<"array1\tarray2"<<endl;
for(j=1;j<2;j++)
{
for(i=1;i<11;i++)
if(a[j]==b[j])
cout<<a[j]<<"\t"<<b[j]<<endl;
else
{
for(i=1;i<11;i++)
if(a[j]!=b[j])
cout<<a[j]<<"\t"<<b[j]<<endl;
else
cout<<"mathch";
}
}
}
}

Please repost using code tags.

[code]

// code here

[/code]

  1. Use iostream, not iostream.h
  2. conio.h is not needed. All it does is complicate things for the rest of us.
  3. Ditto clrscr(). It adds nothing to the program, plus we can't compile it.
  4. Change "void main" to "int main". Lots of threads as to why.
  5. Having an array size of 10 and a loop that goes to 11 is just begging for a seg fault.
  6. Array indexes start at 0, not 1.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.