Nov 29, 2016 at 6:38pm UTC
here is the thing i want to create two vectors and through "FOR" insert the values and then multiply them both with each other.
that is my try pls help
int a, b;
vector<int>numbers1;
vector<int>numbers2;
for(int i=1;i<5;i++)
{
cin >> a;
numbers1.push_back(a);
}
for (int j = 1; j<5; j++)
{
cin >> b;
numbers2.push_back(b);
}
for(int i=0;i>100;i++)
{
cout << setw(3) << numbers1[i] * numbers2[i];
}
cout << endl;
Nov 29, 2016 at 7:11pm UTC
You only fill the first 4 positions in both vectors with numbers but then you try to multiply the numbers in the vectors through the first 100 positions but there are only numbers in the first 4. Use something like:
1 2 3 4 5 6 7
int size = numbers1.size();
for (int i=0;i<size;i++)
{
cout << setw(3) << numbers1[i] * numbers2[i];
}
Last edited on Nov 30, 2016 at 12:04am UTC
Nov 29, 2016 at 9:24pm UTC
i know but the positions don't mean to much the problem is i need the numbers i tipped in to multiply with each other
Nov 29, 2016 at 9:26pm UTC
i know there has to be a for in for loop to multiply them like in making an multiplication table but how?????????????????? i'm getting mand
Nov 30, 2016 at 10:03am UTC
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa it work's you saved my I almost lost my mind (just kidding hahaha :D) thx very very much :D