C Program to Find Common Array Elements Last Updated : 03 Aug, 2022 Comments Improve Suggest changes Like Article Like Report Here, we will see how to find the common array elements using a C program. Input: a[6] = {1,2,3,4,5,6} b[6] = {5,6,7,8,9,10} Output: common array elements is 5 6 C // C program to find the common array elements #include <stdio.h> int main() { int a[6] = { 1, 2, 3, 4, 5, 6 }; int b[6] = { 5, 6, 7, 8, 9, 10 }; int c[10], i, j, k = 0, x, count; for (i = 0; i < 7; i++) { for (j = 0; j < 7; j++) { // checking if element in // array 1 is equal to // the element in array 2 if (a[i] == b[j]) { count = 0; for (x = 0; x < k; x++) { if (a[i] == c[x]) count++; } // storing common elements in c array if (count == 0) { c[k] = a[i]; // incrementing the k value to store the // size of array 3 k++; } } } } printf("Common array elements is \n"); for (i = 0; i < k; i++) // printing the result printf("%d ", c[i]); return 0; } Outputcommon array elements is 5 6 Comment More infoAdvertise with us Next Article C Program to Find Common Array Elements L laxmigangarajula03 Follow Improve Article Tags : C Programs C Language C Array Programs Similar Reads C Program to Find Common Array Elements Between Two Arrays Here we will build a C Program to Find Common Array Elements between Two Arrays. Given two arrays we have to find common elements in them using the below 2 approaches: Using Brute forceUsing Merge Sort and then Traversing Input: array1[] = {8, 2, 3, 4, 5, 6, 7, 1} array2[] = {4, 5, 7, 11, 6, 1} Outp 4 min read C program to count frequency of each element in an array Given an array arr[] of size N, the task is to find the frequency of each distinct element present in the given array. Examples: Input: arr[] = { 1, 100000000, 3, 100000000, 3 } Output: { 1 : 1, 3 : 2, 100000000 : 2 } Explanation: Distinct elements of the given array are { 1, 100000000, 3 } Frequenc 4 min read Array C/C++ Programs C Program to find sum of elements in a given arrayC program to find largest element in an arrayC program to multiply two matricesC/C++ Program for Given an array A[] and a number x, check for pair in A[] with sum as xC/C++ Program for Majority ElementC/C++ Program for Find the Number Occurring Odd N 6 min read C Program to Remove Duplicates from Sorted Array In this article, we will learn how to remove duplicates from a sorted array using the C program.The most straightforward method is to use the two-pointer approach which uses two pointers: one pointer to iterate over the array and other to track duplicate elements. In sorted arrays, duplicates are ad 4 min read How to Search in Array of Struct in C? In C, a struct (short for structure) is a user-defined data type that allows us to combine data items of different kinds. An array of structs is an array in which each element is of struct type. In this article, we will learn how to search for a specific element in an array of structs. Example: Inpu 2 min read Like