Question is:
Declare two arrays of size 5. Get input from the user. Declare a third array of size 10. Put the values of array1 in even indexes of array3 and values of array2 in odd indexes of array3.
Example
Array1
1 2 3 4 5
Array2
6 7 8 9 10
Array3 will be
1 6 2 7 3 8 4 9 5 10
im new in C++
and i have getting a problem in this question..please check my code and help me to sort out the problem.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{clrscr();
int a[5];
int b[5];
int c[10];
int s;
for (s=0;s<5;s++)
{cout<<"Enter Element of array 1";
cin>>a[s];}
for (s=0;s<5;s++)
{
cout<<"Enter element of array 2";
cin>>b[s];
}
for (s=0;s<10;s++)
{
if (s%2==0)
{c[s]=a[s];}
else
{c[s]=b[s];}
}
for (s=0;s<10;s++)
{cout<<c[s]<<endl;}
getch();
}