#include <iostream> // Библиотеки #include <cstdlib> #include <ctime> using namespace std; int main() //Главный код { srand(static_cast<unsigned int>(time(0))); //Рандом int RandNum = rand()% 10 + 1; try = 0; int a; cout << "\t Welcome)"<< endl << endl; do{ // Цикл cout << "Enter a number: " cin >> a; ++try; if(a < RandNum){ cout << "To low: "; } else if(a > RandNum){ cout << "To High: "; } else cout << "You got it in " << try << "try" } _getch(); return 0; } 

gives an error at int try = 0 // Demands for some reason}

Closed due to the fact that off-topic participants are Vladimir Martyanov , VenZell , Abyx , Pavel Parshin , Grundy 16 Feb '16 at 10:30 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reasons:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Vladimir Martyanov, VenZell, Grundy
  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Abyx, Pavel Parshin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • #include <iostream> #include <cstdlib> #include <ctime> #include <conio.h> using namespace std; int main () {srand (static_cast <unsigned int> (time (0))); int RandNum = rand ()% 10 + 1; int a = 0; int a; cout << "\ t Welcome)" << endl << endl; do {cout << "Enter a number:"; cin >> a; ++ a; if (a <RandNum) {cout << "To low:"; } else if (a> RandNum) {cout << "To High:"; } else {cout << "You got it in" << a << "try"} _getch (); return 0; } - Denis SafonoV
  • one
    int missed. - andy.37
  • one
    It would be nice to add a tag of the language in which it is written. - Batanichek
  • 2
    It is advisable to add the full text of the compiler error, and not its free retelling. - newman

1 answer 1

http://ru.cppreference.com/w/cpp/keyword

try is a C ++ keyword; it cannot be used as an identifier.

  • one
    ... and even if try not a keyword, it does not have an ad. This is an addition to the TSA note. - D-side
  • Yes, thanks, I wrote and immediately figured out - Denis SafonoV