Write a program to store 5 elements in the array P and 3 elements in the array Q.Produce a third array R after joining the array P and Q.Display the resultant array.

program to store 5 elements in the array P and 3 elements in the array Q.

  • Sree
  • 30 Jul
  • 4677 Views
  • 1 Answer
Your Answer

#include<stdio.h>
#include<conio.h>
void main()
{
 int p[5],q[3],r[8],i,j;
clrscr();
printf("enter the elements of an array P-\n");
for(i=0;i<5;i++)
scanf("%d",&p[i]);
printf("enter the elements of an array Q-\n");
for(i=0;i<5;i++)
scanf("%d",&q[i]);
printf("After joining P and Q..............-\n");
for(i=0;i<5;i++)
r[i]=p[i];
for(j=0;j<3;j++)
{
 r[i]=q[j];
i++;
}
printf("Total elements of an array R-\n");
for(i=0;i<8;i++)
printf("%d\n",r[i]);
getch();
}
 

0
c programming
Practice Mock Test
c programming