/* C Program - Merge Two Arrays */
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int arr1[50], arr2[50], size1, size2, size, i, j, k, merge[100];
printf("Enter Array 1 Size : ");
scanf("%d",&size1);
printf("Enter Array 1 Elements : ");
for(i=0; i<size1; i++)
{
scanf("%d",&arr1[i]);
}
printf("Enter Array 2 Size : ");
scanf("%d",&size2);
printf("Enter Array 2 Elements : ");
for(i=0; i<size2; i++)
{
scanf("%d",&arr2[i]);
}
for(i=0; i<size1; i++)
{
merge[i]=arr1[i];
}
size=size1+size2;
for(i=0, k=size1; k<size && i<size2; i++, k++)
{
merge[k]=arr2[i];
}
printf("Now the new array after merging is :\n");
for(i=0; i<size; i++)
{
printf("%d ",merge[i]);
}
getch();
}Monday, 28 August 2017
C Program - Merge Two Arrays
Subscribe to:
Post Comments (Atom)
C-Program to know whether the character is vowel or not
#include<stdio.h> int main() { char c; printf("Enter a character to know whether it is vowel or not\n"); scanf("...
-
Various Operations On An Array: Insert an element to an array Delete an element from an array Traverse the given array Search an element in...
-
Call Taxi Booking import java.util.Scanner; public class Main { public static v...
-
Spiral Matrix Assume the size of the matrix is odd. Sample Input: 3 1 2 3 4 5 6 7 8 9 S...
No comments:
Post a Comment