#include<stdio.h>
#include<conio.h>
void main()
{
int j,h=0,k=0;
int x[4]={1,2,3,4};
int y[4]={5,6,7,8};
int z[8];
clrscr();
printf(“array x:\n”);
for(j=0;j<4;j++)
printf(“%d”,x[j]);
printf(“array y:\n”);
for(j=0;j<4;j++)
printf(“%d”,y[j]);
j=0;
while(j<8)
{
if(j%2==0)
z[j]=x[k++];
else
z[j]=y[h++];
j++;
}
printf(“array z:\n”);
for(j=0;j<8;j++)
printf(“%d”,z[j]);
getch();
}
Output:
array x:
1 2 3 4
array y:
5 6 7 8
array z:
1 2 3 4 5 6 7 8
No comments:
Post a Comment