Simple: you are declaring an array of six values:
int v1[6];
But they you always use the same value to store or access data:
cin>>v1[6];
...
if(v1[6] == 1)
...
else if(v1[6] == 2)
And worse: that value doesn't exist!
When you declare an array of N values, you access each of them by using an index, which is a numeric value betwen 0 and N - 1.
So if you declare a three value array of integers:
int arr[3];
You can access then using indexes between 0 and 2 inclusive:
cin >> arr[0];
cout << arr[1];
arr[2] = 666;
Elements with values below zero and above 2 do not exist, and will cause some very odd bugs in your code (if the compiler you use isn't set to check array bounds and throw an error is you go outside them).
To fill an array of
n
values in a loop is easy:
int n = 3;
int arr[n];
for (int i = 0; i < n; i++)
{
arr[i] = i + 100;
}
And to print them is equally easy:
for (int i = 0; i < n; i++)
{
cout << arr[i] << ", ";
}
Can I also suggest that you look at the
C++ Switch statement[
^] which will make your code a lot easier to read!