symbol endl and cout could not be resolved

1.5k Views Asked by At

I have written this code from a book i am reading but my complier warns be that symbol cout and endl could not be resolved. Why is that.

#include <iostream>
#include <float.h>

int main()

{
    cout << "float: " << endl
         << "stevilo decimalnih mest: " << FLT_DIG         << endl
         << "natancnost stevila....: " << FLT_EPSILON      << endl
         << "Najmanjse stevilo.....: " << FLT_MIN          << endl
         << "Najvecje stevilo......: "  << FLT_MAX         << endl
         << "Bitov v mantisi.......: "  << FLT_MANT_DIG    << endl
         << "Najvecji eksponent....: "  << FLT_MAX_10_EXP  << endl
         << "Najmlajsi eksponent...: "  << FLT_MIN_10_EXP  << endl;

    return 0;
}
2

There are 2 best solutions below

0
On

cout and endl are scoped. So you have to inform in which namespace there are.

Use

std::cout
std::endl

or badly add just after include

using namespace std;
2
On

You would have to use namespace:

#include <iostream>
#include <float.h>
using namespace std;

or:

std::cout

You can read more about namespaces in c++ here