{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

12_ArraysB(Oct.21)

# 12_ArraysB(Oct.21) - APSC160 Arrays B Oct.21-2010...

This preview shows pages 1–5. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
APSC160 Arrays B Oct.21-2010 Q4 (ArraysTwoSizeOfIntersection.c) /*main & 2 functions with reuse of Q3 s search function*/ /* * Determine how many duplicate integers are found in two * arrays, each of which is filled with unique elements. * For example, if the value 99 appears in array1 AND * in array2, then add one to the count of the number of * elements found in both arrays. * * Author: Ed Knorr * Date: October 21, 2010 * Lab Section: L1X * * Version: 1 (one function calls another; no nested loops) */ #include <stdio.h> #include <stdlib.h> /* here are the sizes of the arrays I'm using */ #define SIZEA 5 #define SIZEB 6 #define SIZEC 3 #define SIZED 3 /* declare function prototypes */ int compare_arrays( int array1[ ], int size1, int array2[ ], int size2 ); int search( int array[ ], int size, int toFind ); int main( void ) { int num_duplicates; /* here are the arrays I'm using */ int arrayA[ ] = { 3, 6, 1, 2, -4 }; int arrayB[ ] = { 7, 9 -1, 2, 6, 8 }; int arrayC[ ] = { 4, 7, 11 }; int arrayD[ ] = { -1, 3, 12 }; num_duplicates = compare_arrays( arrayA, SIZEA, arrayB, SIZEB ); printf( "We found %d duplicates in the arrays\n", num_duplicates ); num_duplicates = compare_arrays( arrayC, SIZEC, arrayD, SIZED );
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

12_ArraysB(Oct.21) - APSC160 Arrays B Oct.21-2010...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online