There are 3 possible reasons of this error.
- You are missing the header file <iostram> in you program
- You are not using std:: before cout in your main program ( if you did not declare it before main program ).
- You are missing using namespace std before main program.
Here is an example in which using namespace std is missing and also did not use std:: before cout statement so we have error ” cout was not declared in this scopes “.
How to solve ” cout was not declared in this scope error ?
There are three ways to solve this error.
1st way to solve is to put std:: before cout and use std:: every time when you put cout statement in your program.
Declare using std::cout before main function so you will not face ” cout was not declare in this scope error “.
You can put using namespace std before main program so that you don’t have to use std:: before every cout statement in your program. See picture below after solving this error with using namespace std.
Use ” using namespace std ” before main program so that you will not have to face this ” cout was not declare in this scope ” error and you will not have to use std:: before using cout statement.