Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Working with switch case



Specifer



" ; " after loop



Test expression



Comment




Array_print whether two array are equal or not




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include<stdio.h> #include<math.h> #define pf printf #define N 100 //at a time defining array size int main() { int arr1[N],arr2[N],n1,n2,i,j,flag=0; //taking first array size pf("Enter the number of element in the first array: "); scanf("%d",&n1); //taking the element of the first array pf("\nEnter the array element: "); for(i=0;i < n1;i++) scanf("%d",&arr1[i]); //taking the size of the second array pf("\nEnter the number of element in the second array: "); scanf("%d",&n2); //taking the element of the second array pf("\nEnter the element of the second array: "); for(i=0;i < n2;i++) scanf("%d",&arr2[i]); //testing area starts //checking the equality if(n1!=n2) { pf("\nThe two array are not equal."); } else { //checking the equality of two array element for(i=0;i < n1;i++) { if(arr1[i]!=arr2[i]) //that if every element is equal then the statement is true { flag=1; break; } } if(flag==0) pf("\nThe two array are equal."); else pf("\nThe two array are not equal."); } return 0; }
OUTPUT:


© 2018 - All rights reserved