C++ Programming Exercises Static
C++ Programming Exercises Static
C++
Programming/Exercises
/Static arrays/Pages
< C++ Programming | Exercises | Static arrays
Static arrays
EXERCISE 1
Solution #1
#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
int a[10],i,b=0,N=10;
//declaration
cout<<"Enter the array:\n";
//enter 10 number
for(i=0;i<N;i++) //for loop
to gather data
{
cin>>a[i]; //arrays of 10
integers
if (a[i]>=10) //check
whether the integers are greater
or equal to 10
b++; //in crement
}
Solution #2
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
//-------------------------------
---------------------------------
-----------
void outputFunc(int array[]);
inputFunc(array);
outputFunc(array);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int array[])
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array[" << count
<< "]: ";
while(! (cin >>
array[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array[" <<
count << "]: ";
}
fflush(stdin);
}
}
return count;
}
Solution #3
//by blazzer12
//input 10 integers and print
number of integers grater than or
equal to 10
#include <iostream>
int main()
{
const int limit = 10;
int list[10], count=0;
(list[i]<10) ? : count++;
//observe closely and if needed,
recall the syntax of ?: operator
}
cout<<"Number of interger(s)
greater than 10 = "<<count;
}
Solution #4
#include <iostream>
using namespace std;
int main () {
int i; //"for" loop counter
//EXERCISE 1
int cinArray1; //integer
value of array indexes
int overTen = 0; //integer
value of the amount of numbers in
the array that are greater than
ten, starts of at 0 as we do not
know yet
int array1[10]; //array of 10
integers
cout << "Enter 10 numbers for
array1. ";
for (i = 0; i < 10; i++) {
//for loop to gather data
cout << "Enter number "
<< (i + 1) << ": ";
cin >> cinArray1;
array1[i] = cinArray1; }
for (int j = 0; j < 10; j++)
{
if (array1[j] > 10) {
overTen++;}
}
cout << "There are " <<
overTen << " numbers in array1
that are greater than ten.";
cin.get();
cin.get();
Solution #5:
#include <iostream>
using namespace std;
int main()
{
int arr[10],
n,greaterIntergers = 0;
return 0;
}
Solution #6:
#include <iostream.h>
#include <conio.h>
void main()
{
int no[10],i,c=0;
for(i=0;i<10;i++)
{
cin>>no[i];
if(no[i]>=10)
c++;
}
cout<<"Number Greater or
Equal to 10 are"<<c;
getch();
}
Solution #7:
#include <iostream>
using namespace std;
void searching(int[]);
void printarray(int[]);
void main() {
int array[10];
Solution
Solution #1
#include <iostream>
int main ()
{
int t[N], i=0, V;
return 0;
}
Solution #2
#include <iostream>
using namespace std;
int main(void)
{
int V,input[10];
bool equalsV(false);
for(int currentBlock(0);
currentBlock < 10;
currentBlock++)
{
cout << "Enter input[" <<
currentBlock << "]: ";
cin >>
input[currentBlock];
if (input[currentBlock]
== V)
equalsV = true;
}
system("PAUSE");
return 0;
}
Solution #3
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
//-------------------------------
---------------------------------
-----------
void outputFunc(int array[], int
V);
inputFunc(array, V);
outputFunc(array, V);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int array[], int&
V)
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array[" << count
<< "]: ";
while(! (cin >>
array[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array[" <<
count << "]: ";
}
fflush(stdin);
}
if(! (testFunc(array, V) ) )
cout << "not ";
cout << "in the array.\n" <<
endl;
}
Solution #4
// by blazzer12
// input 10 integers into an
array. Find if an integer(that is
input by user) is in the array.
#include<iostream>
#include<conio.h>
while(count<10)
{
cout<<"Enter Number "
<<count+1<<" : "; //count+1
because it prints from 1,2,3..
not from 0. Value of count is not
affected
cin>>arrNum[count++]; //
post increaments count by one
}
if(found)
cout<<"V is in the
array";
else
cout<<"V is not in the
array";
}
Solution #5
//By iCheats---------------------
---------------------------------
--------//>
#include <iostream>
//variables
int basArray[10];
int askNum;
int V;
bool youWin = false;
int main()
{
while(1)
{
for (int f = 0; f < 10;
f++)
{
cout << "Type a
number: ";
cin >>
basArray[askNum];
}
if (youWin)
{
cout << "V is in the
array";
break; // exit
program
}
else
{
cout << "V is not in
the array";
}
}
return 0;
}
Solution #6
#include <iostream>
using namespace std;
int main()
{
int arr[10], intergerV, n;
bool inArray;
cout << "Type an Interger:
(it will be labaled Integer V):
";
cin >> intergerV;
for (int n = 0; n < 10; n++)
{
cout << "Type an integer:
";
cin >> arr[n];
if (intergerV == arr[n]) {
inArray = true;
}
}
if (inArray)
cout << "Interger V is in
the Array";
else
cout << "Integer V is not
in the Array";
return 0;
}
by MAK JUNIOR
#include <iostream>
#include <stdio.h>
int main() {
}
EXERCISE 3
Solution
Solution #1
#include <iostream>
using namespace std;
#include <iostream>
using namespace std;
int main()
{
int index = 0, nb = 0;
int arr [10];
Solution #3
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
//-------------------------------
---------------------------------
-----------
void outputFunc(int array[]);
inputFunc(array);
outputFunc(array);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int array[])
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array[" << count
<< "]: ";
while(! (cin >>
array[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array[" <<
count << "]: ";
}
fflush(stdin);
}
}
Solution #4:
#include <iostream>
using namespace std;
void LargestElement(int arg[],
int list) {
int Index;
int Largest = arg[0];
LargestElement(UserArray,
10);
return 0;
//By David J
#include <iostream>
int main()
{
int arr[SZ];
int Largest = 0, index = 0;
cout << "Please enter " << SZ
<< " integers:" << endl;
for (int i = 0; i < SZ; i++)
{
cin >> arr[i];
}
return 0;
}
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int size;
cout<<"enter the size of
array\n";
cin>>size;
ray[size];
for(int i=0;i<size;i++)
{
cout<<"\n\n enter the "
<<i+1<<" element of array";
cin
>>array[i];
}
int p=array[0];
int index;
for(int i=0;i<size;i++)
{
if(p<array[i])
{
p=array[i];
index=i;
}
}
cout<<"\nthe largest
element of an array is "<<p;
cout<<"\n\nthe
index of the valus is "<<index;
getch();
return 0;
}
EXERCISE 4
Solution
Solution #1
#include <iostream>
using namespace std;
int main()
{
int t[N],i,j,V;
bool found;
for(i=0;i<N;i++)
{
cout << "Type an integer:
";
cin >> t[i];
}
cout << "Type the value of V:
";
cin >> V;
for (i=0;i<N;i++)
if (t[i]==V)
{
for (j=i;j<N-1;j++)
t[j]=t[j+1];
t[N-1]=0;
break;
}
for(i=0;i<N;i++)
cout << t[i] << endl;
return 0;
}
Solution #2
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
//-------------------------------
---------------------------------
-----------
void outputFunc(int array[], int
V);
inputFunc(array, V);
outputFunc(array, V);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int array[], int&
V)
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array[" << count
<< "]: ";
while(! (cin >>
array[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array[" <<
count << "]: ";
}
fflush(stdin);
}
// by blazzer12
#include <iostream>
#include <cstdlib>
#define SIZE 4
int getSearchCriteria()
{
int V;
cout<<endl<<endl<<"Please
enter the integer you want to
find (V) = ";
cin>>V;
return V;
}
for(index = 0; notFound
&& index<SIZE; index++)
{
if(y[index]==s)
notFound=false;
}
if (notFound)
{
cout<<endl<<"Element "<<s<<" is
not found."<<endl;
index = 0;
}
else
{
cout<<endl<<"Element "<<s<<" is
found at array["<<index-1<<"]"
<<endl;
}
return index-1;
}
z[SIZE-1]=0;
}
int main()
{
int
array[SIZE],V,location=-1;
char choice;
bool tryAgain=false;
do
{
// ask user the
element to be searched for
V=getSearchCriteria();
// search V and
report
location =
searchArray(array,V);
if(location==-1)
{
cin>>choice;
if(choice
== 'Y' || choice == 'y')
tryAgain = true;
else
exit(0);
}
else
tryAgain=
false;
}while(tryAgain);
deleteElement(array,location);
cout<<endl<<"Element "
<<V<<" at array["<<location<<"]
is deleted!"<<endl;
// diplay array;
display(array);
return 0;
}
Solution #4
//By David J
#include <iostream>
int main()
{
int arr[SZ];
int V;
cout << "Please enter 10
integers: " << endl;
for (int i = 0; i < SZ; i++)
{
cin >> arr[i];
}
cout << "Enter V: ";
cin >> V;
return 0;
}
EXERCISE 5
Solution
Solution #1
#include <iostream.h>
#include <conio.h>
int main()
{
int insert;
int index1;
int num_in[10];
//array[index]=ins;
for(int index1=0; index1<=9;
index1++)
if (index1==index)
array[index1]=ins;
for(index1=0;
index1<=9;index1++)
cout << array[index1] <<
endl;
for(index1=0; index1<=9;
index1++)
{
if(array[index1]==ins &&
index1<9)
{
temp = array[index1];
array[index1]=array[index1+1];
array[index1+1]=temp;
}
}
for(index1=0;
index1<=9;index1++)
cout << array[index1] <<
endl;
}
Solution #2
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
//-------------------------------
---------------------------------
-----------
void outputFunc(int array[], int
V, int i);
inputFunc(array, V, i);
outputFunc(array, V, i);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int array[], int&
V, int& i)
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array[" << count
<< "]: ";
while(! (cin >>
array[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array[" <<
count << "]: ";
}
fflush(stdin);
}
return newArrayPtr;
}
Solution #3
// By J0nDaFr3aK
#include <iostream>
using namespace std;
#define LENGTH 10
int main()
{
int array[LENGTH], v, i(-1),
j, temp1, temp2;
for (j = 0; j < LENGTH; j++)
{
cout << "enter number: ";
cin >> array[j];
}
do {
cout << "\nenter value of
i (0 to " << LENGTH - 1 << "): ";
cin >> i;
} while (i < 0 || i > LENGTH
- 1);
array[j] = temp2; // j ==
LENGTH - 1 (9)
return 0;
}
Solution #4
// By Tinnin
// Inserting element into array
#include <iostream>
using namespace std;
int main()
{
int array[10], V, i;
cout << "Enter ten integers
into the array: \n";
for(int j=0;j<10;j++)
{
cin >> array[j];
}
for(int j=0;j<10;j++)
{
cout << array[j] << " |
";
}
cout << "\nEnter an integer V
to insert into the array: ";
cin >> V;
cout << "Choose the index i
between 0 and 9 at which to enter
V: ";
cin >> i;
while(i<0||i>9)
{
cout << "Choose the index
i between 0 and 9 at which to
enter V: ";
cin >> i;
}
for(int j=0;j<10;j++)
{
if(j==(i+1))
{
for(int k=9;k>i;k--)
{
array[k]=array[k-
1];
}
break;
}
}
array[i]=V;
for(int j=0;j<10;j++)
{
cout << array[j] << " |
";
}
return 0;
}
Solution #5
//by David J
#include <iostream>
int main()
{
int arr[SZ];
int V, i;
cout << "Please enter 10
integers: " << endl;
for (int x = 0; x < SZ; x++)
{
cin >> arr[x];
}
cout << "Enter value to
insert in array: ";
cin >> V;
cout << "Enter Index (0-9) to
place the value: ";
cin >> i;
while (i < 0 || i > 9)
{
cout << "Index must be
within range 0-9: ";
cin >> i;
}
int z = SZ-1;
while (z != i)
{
arr[z] = arr[z-1];
z--;
}
arr[i] = V;
return 0;
}
Solution #6
#include <iostream>
//by YC CHAN
using namespace std;
int main() {
int array[10], V, index=10;
for (int i = 0; i < 10; i++)
{
cout << "please enter a
number into array[" << i << "]:
";
cin >> array[i];
}
cout << "please enter the
value V: ";
cin >> V;
while (index< 0 || index> 9)
{
cout << "please enter the
index value(0 - 9): ";
cin >> index;
}
for (int j =9; j > index; j-
-) {
array[j] = array[j - 1];
}
array[index] = V;
for (int i = 0; i < 10; i++)
{
cout << "array[" << i <<
"] is: " << array[i] << endl;
}
}
EXERCISE 6
Solution
Solution #1
#include <iostream>
using namespace std;
int main()
{
int a[N],i;
bool found=false;
bool up=false,down=false;
Solution #2
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
//-------------------------------
---------------------------------
-----------
void outputFunc(bool increasing,
bool decreasing);
inputFunc(array, increasing,
decreasing);
outputFunc(increasing,
decreasing);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int array[], bool&
increasing, bool& decreasing)
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array[" << count
<< "]: ";
while(! (cin >>
array[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array[" <<
count << "]: ";
}
if(array[count] <
array[count - 1] && count != 0)
decreasing = true;
else if(array[count] >
array[count - 1] && count != 0)
increasing = true;
fflush(stdin);
}
}
Solution #3
// by blazzer12
#include <iostream>
#define SIZE 10
int main()
{
int numbers[SIZE];
bool increase=false,
decrease=false;
cout<<"Welcome, enter
integers to know the nature of
sequence."<<endl;
while(!(cin>>numbers[i]))
{
// avoid and handle
invalid input
cin.clear();
cin.ignore(10000,
'\n');
cout<<"Expected
Integer, please try again."
<<endl;
cout<<"numbers["
<<i<<"] = ";
}
if(numbers[i+1]>numbers[i])
increase = true;
if(numbers[i+1]
<numbers[i])
decrease = true;
}
// print result
Solution #4:
#include <iostream>
using namespace std;
int main()
{
int a[N],i;
bool found=false;
bool up=false,down=false;
cout<<"increasing and
decreasing";
else if(up)
cout<< "increasing";
else if (down)
cout<< "decreasing";
else if (!(up&&down))
cout<< "constant" <<
endl;
system("pause");
return 0;
}
Solution #5:
// by Ismail Zouaoui
#include <iostream>
int main()
{
int const SIZE = 10;
int arr[SIZE];
bool order = true;
return 0;
}
Solution #6:
// by YC CHAN
#include<iostream>
using namespace std;
bool increase(int a[]) {
for (int i = 0; i < 9; i++) {
if (a[i + 1] > a[i]) {
return true;
}
}
return false;
}
bool decrease(int a[]) {
for (int j = 0; j < 9; j++) {
if (a[j + 1] < a[j]) {
return true;
}
}
return false;
}
int main() {
int array[10];
for (int i = 0; i < 10; i++)
{
cout << "please enter a
number into array[" << i << "]:
";
cin >> array[i];
}
if (increase(array) &&
!decrease(array)) {
cout << "the array is
growing. "<<endl;
}
else if (decrease(array) &&
!increase(array)) {
cout << "the array is
decreasing. "<<endl;
}
else if (increase(array) &&
decrease(array)) {
cout<<"the array is
growing and decreasing."<<endl;
}
else {
cout << "the array is
constant"<<endl;
}
return 0;
}
EXERCISE 7
Solution
Solution #1
#include <iostream>
using namespace std;
int main()
{
int a[N],i,j,min,imin,tmp;
for (i=0;i<N;i++)
{
cout << "Please enter an
integer: ";
cin >> a[i];
}
for (i=0;i<N-1;i++)
{
imin=i;
min=a[i];
for (j=i+1;j<N;j++)
if (a[j]<min)
{
min=a[j];
imin=j;
}
tmp=a[imin];
a[imin]=a[i];
a[i]=tmp;
}
cout << "The sorted array:"
<< endl;
for (i=0;i<N;i++)
cout << "a[" << i << "] = "
<< a[i] << endl;
return 0;
}
Solution #2
#include <iostream>
using namespace std;
const int N=10;
int main()
{
int a[N],i,nb,tmp;
for(i=0;i<N;i++)
{
cout << "Please enter an
integer: ";
cin >> a[i];
}
do {
nb=0;
for (i=0;i<N-1;i++)
if (a[i]>a[i+1])
{
tmp=a[i];a[i]=a[i+1];a[i+1]=tmp;
nb++;
}
} while(nb!=0);
return 0;
}
Solution #3
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
//-------------------------------
---------------------------------
-----------
void outputFunc(int array[]);
inputFunc(array);
outputFunc(array);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int array[])
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array[" << count
<< "]: ";
while(! (cin >>
array[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array[" <<
count << "]: ";
}
fflush(stdin);
}
}
void sortFunc(int array[])
{ for(int startIndex = 0;
startIndex < X; ++startIndex)
{ int smallestIndex =
startIndex;
for(int currentIndex =
startIndex + 1; currentIndex < X;
++currentIndex)
if(array[currentIndex] <
array[smallestIndex])
smallestIndex =
currentIndex;
swap(array[smallestIndex],
array[startIndex]);
}
}
sortFunc(array);
Solution #4
// By J0nDaFr3aK
#include <iostream>
using namespace std;
#define LENGTH 10
int main()
{
int array[LENGTH], i, j,
lowest, index, temp;
// input
for (i = 0; i < LENGTH; i++)
{
cout << "enter value " <<
i << ": ";
cin >> array[i];
}
// sorting
for (i = 0; i < LENGTH; i++)
{
lowest = array[i];
index = i;
for (j = i; j < LENGTH;
j++) {
if (array[j] <
lowest) {
lowest = array[j];
// saves lowest number
index = j;
// saves position index of lowest
number
}
}
temp = array[i];
array[i] = lowest;
array[index] = temp;
}
// prints array
for (i = 0; i < LENGTH; i++)
cout << array[i] << " ";
return 0;
}
Solution #5
// by J0nDaFr3aK
#include <iostream>
using namespace std;
#define LENGTH 10
void input(int array[], int
size);
void sorting(int array[], int
size);
void display(int array[], int
size);
int i;
int main()
{
int array[LENGTH];
return 0;
Solution #6
//By David J
#include <iostream>
int main()
{
int arr[SZ];
cout << "Enter 10 integers:"
<< endl;
for (int i = 0; i < SZ; i++)
{
cin >> arr[i];
}
Solution #7 by xeeshan
#include<iostram>
using namespace std;
int main()
{
int a[10]=
{33,10,1,87,6,44,23,3,11,82};
int i,j,temp;
int N=10;
}
Solution #8
#include<iostream>
//by YC CHAN
using namespace std;
int main() {
int array[10], temp;
for (int i = 0; i < 10;
i++) {
cout << "please enter
a number into array[" << i << "]:
";
cin >> array[i];
}
for(int i=0;i<10;i++){
for (int j = 9; j >
0; j--) {
temp = array[j];
if (array[j] <
array[j - 1]) {
temp =
array[j - 1];
array[j - 1]
= array[j];
array[j] =
temp;
}
}
}
for (int k = 0; k < 10;
k++) {
cout << "array[" << k
<< "] is: " << array[k] << endl;
}
return 0;
}
EXERCISE 8
Solution
Solution #1
#include <iostream>
using namespace std;
const int N=10;
int main()
{
int a[N],b[N],c[2*N],i;
Solution #2
//------------------------- By
Brandon Cox ---------------------
-------------
#include <iostream>
using namespace std;
#define X 10
#define Y 10
//-------------------------------
---------------------------------
-----------
void outputFunc(int a[], int
b[]);
inputFunc(a, b);
outputFunc(a, b);
system("pause");
return 0;
}
//-------------------------------
---------------------------------
-----------
void inputFunc(int a[], int b[])
{ cout << "Please enter " << X
<< " integer elements of an
array.\n" << endl;
for(int count = 0; count < X;
++count)
{ cout << "array a[" << count
<< "]: ";
while(! (cin >> a[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array a[" <<
count << "]: ";
}
fflush(stdin);
}
cout << "\nPlease enter " << Y
<< " integer elements of another
array.\n"
<< endl;
for(int count = 0; count < Y;
++count)
{ cout << "array b[" << count
<< "]: ";
while(! (cin >> b[count]) )
{ cout << "\n\tSorry,
invalid input... was expecting an
integer."
<< " Please try
again:\n" << endl;
cin.clear();
cin.ignore(10000, '\n');
cout << "array b[" <<
count << "]: ";
}
fflush(stdin);
}
}
Solution #3
// by blazzer12
#include <iostream>
#define SIZE 10
#define dSIZE SIZE*2
delete x;
delete y;
return tempArray;
}
int main()
{
int A[SIZE];
int B[SIZE];
int *C;
cout<<"\t\tWELCOME"<<endl;
cout<<"Array B is appended to
array A. Then stored in C and
displayed."<<endl;
//display C
display(C);
return 0;
}
Solution #4
// by J0nDaFr3aK
#include <iostream>
using namespace std;
#define LENGTH 10
int main()
{
int a[LENGTH], b[LENGTH],
c[LENGTH*2], i;
return 0;
}
Solution #5
#include<iostream>
//by YC CHAN
using namespace std;
int main() {
int
array[10],array1[10],array2[20];
for (int i = 0; i < 10;
i++) {
cout << "please enter
a number into array[" << i << "]:
";
cin >> array[i];
}
for (int j = 0; j < 10;
j++) {
cout << "please enter
a number into array1[" << j <<
"]: ";
cin >> array1[j];
}
for (int k = 0; k < 10;
k++) {
array2[k] = array[k];
array2[k + 10] =
array1[k];
}
for (int k = 0; k <
20; k++) {
cout << "array2["
<< k << "] is: " << array2[k] <<
endl;
}
return 0;
}