Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Problem in coding in Dev C++?
Hi I have just downloaded dev C++
n wrote a simple program:
#include<iostream>
main ()
{
cout<< "Hello!";
}
on compiling it is returning an error in the line with cout. saying cout undeclared.
is my coding wrong? or are there some settings changes needed to be done in the software?
thanks it worked.
3 Answers
- tbshmkrLv 71 decade agoFavorite Answer
Small changes.
=
ONE to make it work, TWO to bring to standard.
- http://www.cplusplus.com/doc/tutorial/program_stru...
- - - - -
#include<iostream>
using namespace std; // add to make work
int main()
{
cout << "Hello!";
return 0;
}
-
Which text are you using?
Source(s): - http://www.cplusplus.com/doc/tutorial/ - 1 decade ago
Your code is correct to a point, you forgot one line.
#include<iostream>
using namespace std;
main ()
{
cout<< "Hello!";
return 0; /*it's good to get in the habit of returning your programs, return 0 shows that the program ran just fine. It may seem kinda pointless now, but when writing bigger programs they are good for showing where things went wrong.*/
}
Cout and Cin, for example. Are a part of the std:: namespace, so unless you add using namespace std in your includes(preprocessor) section, you will return an error. It's like referring to a town without naming the country or state it's in.
EDIT:
Another way this could have been done was by doing it this way:
#include<iostream>
main ()
{
std::cout<< "Hello!";
return 0;
}
but this is generally inconvenient.