#include <iostream>
usingnamespace std;
int main()
{
int nu;
int num [7];
int arra[6];
cout <<"enter the numbers in your array (has to be 6(six)digets long)"<<endl;
for(int t=0;t<6; t++)
{
cout<<t<<endl;
cin>>arra[t];
}
cout<<"what number do you want to insert:";
cin>>nu;
cout<<""<<endl;
for(int t=0;t<6; t++)
{
cout<<arra[t]<<", ";
}
cout<<""<<endl;
num[0]=arra[0];
num[1]=nu;
num[2]=arra[1];
num[3]=arra[2];
num[4]=arra[3];
num[5]=arra[4];
num[6]=arra[5];
for(int o=0; o<7;o++)
{
cout<<num[o]<<", ";
}
return 0;
}
The problem with your code is that it always inserts at num[1]. That's fine if you don't care about the ordering of your numbers. If you don't care about the ordering, it's generally easier to copy the array and add to the end of the new array.