Arrays

How i write this code? No I will explain the code clearly?
some one help me....!:(
Example of two identical (Exactly same) arrays:

Array1 Array2
1 1
2 2
3 3
5 5
7 7
9 9
11 11
13 13
15 15
17 17


Example of two arrays with some matching elements:

Array1 Array2
1 7
2 9
3 3
5 4
7 6
9 8
11 11
13 15
8 8
17 17

Here elements on index 3, 7, 9, and 10 of both arrays are same.



Detailed Description:

The program should take 10 integer inputs from user in arrray1 and array2.
• After taking inputs in both arrays, you should pass both arrays to a function named match.
• If both arrays are exactly same, the program should display a message “Both arrays are identical”.
• If both arrays are not exactly same, then program should match the indexes which have same elements in both arrays and display the matching indexes.
• If there is no element matching in both arrays, the program should display a message
“There is no matching element in both arrays”.
• Implementation regarding comparison of arrays and displaying message should be inside the function match.

Sample Output for two exactly same arrays

Please enter 10 integers for array1:
Enter element 1 : 1
Enter element 2 : 3
Enter element 3 : 5
Enter element 4 : 7
Enter element 5 : 9
Enter element 6 : 11
Enter element 7 : 13
Enter element 8 : 15
Enter element 9 : 17
Enter element 10 : 19

Please enter 10 integers for array2:
Enter element 1 : 1
Enter element 2 : 3
Enter element 3 : 5
Enter element 4 : 7
Enter element 5 : 9
Enter element 6 : 11
Enter element 7 : 13
Enter element 8 : 15
Enter element 9 : 17
Enter element 10 : 19

Both arrays are identical


Sample Output for arrays with some matching indexes

Please enter 10 integers for array1:
Enter element 1 : 1
Enter element 2 : 3
Enter element 3 : 5
Enter element 4 : 7
Enter element 5 : 9
Enter element 6 : 11
Enter element 7 : 13
Enter element 8 : 15
Enter element 9 : 17
Enter element 10 : 19

Please enter 10 integers for array2:
Enter element 1 : 2
Enter element 2 : 4
Enter element 3 : 5
Enter element 4 : 6
Enter element 5 : 9
Enter element 6 : 12
Enter element 7 : 14
Enter element 8 : 16
Enter element 9 : 17
Enter element 10 : 20


Both arrays have same elements on
Index 3
Index 5
Index 9
please help me in this code....?
Ill get you started with inputting the first array

notice that i use i+1 to print the element number this is because i starts at zero not one

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <conio.h>
#include <stdio.h>

using namespace std;

int	main(int argc,char** argv)
{
	int	array1[10];
	int	array2[10];

	printf("\n\nPlease enter 10 integers for array1\n");

	for (int i=0;i<10;i++)
	{
		printf("Enter element %d : ",(i+1));

		cin >> array1[i];
	}
}



You should be able to work out inputting the second array from the code given

if you have trouble with the match function just post again and ill try to reply

Hope all this helps
Shredded
Topic archived. No new replies allowed.