Help me to find error in my code

#include
#include

// Define first_three_multiples() here:
int first_three_multiples(int num){
std::vector multiples ;
multiples.push_back(num1);
multiples.push_back(num
2);
multiples.push_back(num*3);
return multiples;
}

int main() {

for (int element : first_three_multiples(8)) {
std::cout << element << “\n”;
}

}

There’s a problem with how you declared the function, and where you declared the vector.

The beginning of the first_three_multiples function should be

std::vector<int> first_three_multiples(int num){
  std::vector<int> multiples;

because you are trying to return a vector of ints, not a single int.
And the type inside the vector would be declared here using <int> .

1 Like