Home c++ Error - undeclared identifier

Error – undeclared identifier

Author

Date

Category

When I program in C++ in Visual Studio , I get an error in the cout and cin statements. The compiler writes that these operators are undeclared identifier. Please tell me what to do?

Added.

Nothing works anyway

# include & lt; iostream & gt;
#include "stdafx.h"
#include & lt; cmath & gt;
using namespace std;
int main () {
  // variable declaration:
  double V, T, alpha;
  // gravel constant:
  const double g = 9.8;
  // Enter parameters:
  cout & lt; & lt; "V ="; - displays an error here
  cin & gt; & gt; V; -and here
  cout & lt; & lt; "T =";
  cin & gt; & gt; T;
  alpha = asin (g * T / 2 * V);
  cout & lt; & lt; "The value of the angle alpha is =" & lt; & lt; alpha;
  return 0;
}

Answer 1, authority 100%


Answer 2, authority 50%


Answer 3, authority 50%

To work properly, you need:

  1. Include the iostream library.
  2. Use using namespace std to resolve scope.

Code example:

# include & lt; iostream & gt;
using namespace std;
int main () {
  cout & lt; & lt; "Hello std!" & lt; & lt; endl;
  return 0;
}

Answer 4

// It is required to create an empty project in VS
#include "stdafx.h"
#include "iostream"
#include & lt; cmath & gt;
#include & lt; conio.h & gt;
using namespace std;
int main () {
setlocale (0, "russian");
// variable declaration:
double V, T, alpha;
// gravel constant:
const double g = 9.8;
// Enter parameters:
cout & lt; & lt; "V ="; // - displays an error here
cin & gt; & gt; V; //-and here
cout & lt; & lt; "T =";
cin & gt; & gt; T;
alpha = asin (g * T / 2 * V);
cout & lt; & lt; "The value of the angle alpha is =" & lt; & lt; alpha;
_getch ();
 }

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions