Search
 
SCRIPT & CODE EXAMPLE
 

C

Write a C program to merge two array to third array.

#include <stdio.h>
 #include <conio.h>
print(int *a,int n)
 {
    int i;



    for(i=0; i<n; i++)
    {

        	printf("%d  ",a[i]);


    }

 }


int main()
{
    int a[100],b[100],c[200],i,n1,n2 ;

    printf("Enter size of the 1st array : ");
    scanf("%d", &n1);
    printf("Enter elements in array : ");
    for(i=0; i<n1; i++)
    {
        scanf("%d",&a[i]);
    }
    printf("Enter size of the 2nd array : ");
    scanf("%d",&n2);

    printf("Enter elements in array : ");
    for(i=0; i<n2; i++)
    {
        scanf("%d",&b[i]);
    }

    for(i=0; i<n1+n2; i++)
    {
       if(i<n1)
          c[i]=a[i];
          else
            c[i]=b[i-n1];

    }

    printf(" 1st array :
");

    print(a,n1);

	printf("
2nd array :
");

    print(b,n2);

	printf("
3rd array :
");

    print(c,n1+n2);

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: mpi example 
C :: Grepper VSCode Add On 
C :: char to int in c 
C :: bitwise and in c 
C :: Example of Implementation of a pointer to an array in C: 
C :: simple calculator, using switch statement in C 
C :: why there is return 0 used in c 
C :: prime factorization in c 
C :: getchar 
C :: typedef c struct 
C :: bubble sort 
C :: addition of matrix 
C :: mongo script to find collection size in database 
C :: malloc c 
C :: FCFS algorithm in c to find average turnaround time and waiting time 
C :: pasar a binario recursivo 
C :: mediawiki upload size 
C :: how to arrange a 2d array based on string length in c 
C :: binary sorting 
C :: c unused variable 
C :: logical operators 
C :: exponentials in c 
C :: len of str vbs 
C :: le reste de division in algorithm c 
C :: run steam as root 
C :: rand in c 
C :: Computers round off numbers 
C :: disable gnu++11 option 
C :: c "hello world" 
C :: c ausgabe von variablen 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =