i'm trying to display the first n numbers on the screen using function, i believe i did everything but it doesn't work
what is wrong with this code??
#include <iostream>
using namespace std;
void printAllIntegers(int x){
for (int i=1; i<=x; i++){
cout << i << endl;
}
}
int main() {
int number;
cout << "Enter an Integer: ";
cin >> number;
cout << "The first " << number << " positive integers are: " << printAllIntegers(number) << endl;
}
printAllIntegers doesn't return anything, so you can't "cout" it's return value. Instead you should call it on a line by itself, after the cout.