Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Test expression



" ; " after loop



Header file



Working with switch case



Iterative statement




Array_merge of two array




// AHF C PROGRAM SOLVING

//solving here 2_D   ARRAY 	programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int i,n1,n2,m,arr1[100],arr2[100],arr3[1000],index=0; //taking data for first array pf("Enter the number of element in the first array: "); scanf("%d",&n1); pf("\nEnter element of the first array: "); for(i=0;i < n1;i++) scanf("%d",&arr1[i]); //taking data for second element pf("\n\nEnter the number element in the second array: "); scanf("%d",&n2); pf("\nEnter the element of the second array: "); for(i=0;i < n2;i++) scanf("%d",&arr2[i]); //calculating new array length m=n1+n2; //joining two array for(i=0;i < n1;i++) { arr3[index]=arr1[i]; index++; } //joining second array with first array for(i=0;i < n2;i++) { arr3[index]=arr2[i]; index++; } //printing new merged array pf("\n\nThe merged array is: "); for(i=0;i < m;i++) pf("\t%d",arr3[i]); return 0; }
OUTPUT:


© 2018 - All rights reserved