I am attempting to write a program that asks for user input of a positive integer larger than 2. The program is supposed to output all the positive integers that are smaller than the user input and that are multiples of 3. However, when running my code I noticed there are two annoying 0’s that keep appearing and aren’t supposed to be there. Any help on how to remove them or make the code better? Thank you!
#include <iostream>
using namespace std;
int get_numbers(int x)
{
for (int i = 0; i < x; i += 3)
{
cout << i << " ";
}
return 0;
}
int main()
{
int integer = 0;
cout << "Enter a positive integer larger than 2: ";
cin >> integer;
cout << get_numbers(integer);
}