If you can figure out what\'s wrong and show me how to fix it, I will rate you a
ID: 3641901 • Letter: I
Question
If you can figure out what's wrong and show me how to fix it, I will rate you a lifesaver :)
int allElements (const vector<int> &F,const vector<int> &S);
int main()
{
//First vector which will be filled with 10 random numbers between 1 and 50
vector <int> firstVector;
int randnums;
const int SIZE = 10;
for(int i=0; i<SIZE; i++)
{
randnums = rand() % 50;
firstVector.push_back (randnums);
}
//Second vector which will be filled with 10 random numbers between 1 and 50
vector <int> secondVector;
int randnums2;
for(int i=0; i<SIZE; i++)
{
randnums2 = rand() % 50;
secondVector.push_back (randnums2);
}
allElements(firstVector, secondVector);
cout << allElements(firstVector, secondVector);
}
int allElements (const vector<int> &F,const vector<int> &S)
{
int count = 0 ;
const int SIZE = 10 ;
for (int i=0; i < SIZE; i++)
{
return F[i] + S[i];
}
}
Explanation / Answer
First of all you must seed the rand() function as
int main()
{
srand(unsigned(time(NULL))) ;
next your random no. expression should be :
randnums = 1 + rand() % 50; //if 1 and 50 are include in the no. to be generated
next delete this line:
cout << allElements(firstVector, secondVector);
and carry out printing in the allElements function :
void allElements (const vector &F,const vector &S)
cout << return F[i] + S[i];
I think that should do it.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.