They give the same output, since they both print the same statement that's in the cout statement.
They don't really work the same. The first version is designed to return an integer value back to the calling function, although there's no code that actually does the return. Your compiler might give you a warning about that. The compiler won't expect a function with return type void to return anything.
A way to use the function to return a value and then do the output in the main function would be something like this.
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
int printCrap(int x){
return 2*x;
}
int main(){
int x = 377;
cout << "The number is " << printCrap(x) << endl;
return 0;
}