endl was not declared in this scope c++ error [ SOLVED ]

0
152

There are three possible reasons of this error and this is the same kind of error cout was not declared in this scope.

  1. You are missing the header file <iostram> in you program
  2. You are not using std:: before endl in your main program ( if you did not declare it before main program ).
  3. 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 endl statement so we have error ” endl was not declared in this scopes “.

endl was not decalred in this scope error in c++

How to solve ” cout was not declared in this scope error ” ?

First put #include <iostram> if you are missing this at the very top of your program then try these three methods.

Solution 1

You can solve this error by putting std:: before endl and use std:: every time when you use endl statement in your program.

solution 1 fro endl was not declared in this scope error

Solution 2

Declare ” using std::endl ” before main function so you will not face ” endl was not declare in this scope error “.

solution 2 for endl was not declared error

Solution 3

You can put using namespace std before main program so that you don’t have to use std:: before every endl statement in your program. See picture below after solving this error with using namespace std.

endl was not decalred in this scope error solution

Suggestions

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 and endl statement.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here