Invalid Iterator argument
Hi, I am trying to create a program that will take 10 numbers and then print the sum of the all two adjacent numbers and then sum of 1st and last,2nd and 2nd last;here is the code
Code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
vector<int> input;
for(int i=0;i!=10;i++)
{
int x;
cin>>x;
input.push_back(x);
}
for(auto it=input.begin();it!=input.end()-1;it++)
{
int k;
k=*it+(*(it+1));
cout<<k<<" "<<endl;
auto j=input.end()-it;
cout<<*it+*j<<" "<<endl;
}
}
.. but at the 2nd output the compiler is giving the error invalid type argument of unary '*'. where am I wrong?