Why does it tell me that I must convert the variable to a constant? If I do this, the code will not be correct.
#include <iostream>
using namespace std;
int main()
{
int number1 , index1;
int newsize = 5;
int size1;
size1 = newsize;
int arr [ size1]={ 77,55,33,44,99 };
cout << "inter your number "; cin >> number1;
cout << "inter your index"; cin >> index1;
cout << " this your array befor eadting \n";
for (int i = 0; i < 5; i++)
{
cout << arr[i] << endl;
}
if (index1 > size1)
{
cout << " your index is faild inter right number betwwen 0 To 4 \n";
}
else
{
for (int ii = size1; ii > index1; ii--)
{
arr[ii] = arr[ii - 1];
}
arr[index1] = number1;
newsize++;
}
cout << " this your array after eadting \n";
for (int i = 0; i < 5; i++)
{
cout << arr[i] << endl;
}
}
Top comments (0)