Why am i getting 'error: ‘cout’ was not declared in this scope' in c++?

Example:

cout << "Hello World!";

This error typically indicates the absence of the appropriate header file or namespace directive for `cout`.

Solution:

Include the necessary header and use the correct namespace.


#include 
using namespace std;

int main() {
    cout << "Hello World!";
    return 0;
}

Beginner's Guide to C++