Why the int main() function gives "Hello world" as the output

int main() {

std::cout << " Hello world\n";
}

The above code gives “Hello world” as the output. If it a function with return type integer, then why it gives output as a string?

1 Like

std::out is responsible for that, which is not a return value

the main function returns the status/error code, 0 is for successful execution, which is implicit returned. Of course we can explicitly add it:

int main() {
    std::cout << " Hello world\n";
    return 0;
}
2 Likes