Programme gives error while compiling

I have written a simple programme but it is not compiling, give these errors
1."cout undeclared first use this function"
2."cin undeclared first use this function"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iosream>
main()
      {
                  //this programme is desighn to seprate the digits of 4 digit number.
                  int number;
                  int digit;
                  //prompt to user to enter the number
                  cout << "Please enter 4 digit number:";
                  cin >> number;
                  digit = number%10;
                  cout << "The digit is:" << digit << "\n";
                  number=number/10;
                  digit=number%10;
                  cout<<"The digit is:"<<digit<<"\n";
                  number=number/10;
                  digit=number%10;
                  cout<<"The digit is:"<<digit<<"\n";
                  number=number/10;
                  digit=number%10;
                  cout<<"The digit is:"<<digit<<"\n";
                  }
                  

Any Solution?
If you're not going to use std::cout and std::cin, then at least put using namespace std; after you include <iostream>
thanks for reply now it gives error
1."cout is not a member of std"
2."cin is not a member of std "
For clarification, pretty much everything in the C++ standard library is in the std namespace, cout and endl included.
And your definition of main is invalid. You forgot to add the return type (int).

thanks for reply now it gives error
1."cout is not a member of std"
2."cin is not a member of std "

The header is called iostream, not iosream.
Last edited on
Now code is given below i have added std::cout and std::cout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
int main()
      {
                  //this programme is desighn to seprate the digits of 4 digit number.
                  int number;
                  int digit;
                  //prompt to user to enter the number
                  std::cout << "Please enter 4 digit number:";
                  std::cin >> number;
                  digit = number%10;
                  std::cout << "The digit is:" << digit << "\n";
                  number=number/10;
                  digit=number%10;
                  std::cout<<"The digit is:"<<digit<<"\n";
                  number=number/10;
                  digit=number%10;
                  std::cout<<"The digit is:"<<digit<<"\n";
                  number=number/10;
                  digit=number%10;
                  std::cout<<"The digit is:"<<digit<<"\n";
                  }

but still not compiling :(
Last edited on
Header's still called iostream.
ok header corrected but actual problem is that programme is not detecting the cout and cin prompts ?
Not really, the error was that it could not find the <iosream> header.
You just missed it, apparently.
but now i have corrected it then why programme is giving errors related to cin and cout?
Then something is wrong with your compiler install. Uninstall it and get a recent version from here:
http://tdm-gcc.tdragon.net/
thanks i am using dev++ 4.9.9.2 is it an old version?
Last edited on
Yes, it is. DevC++ is not a good program to use. The whole thing is old and no longer maintained. How about you try Code::Blocks? http://www.codeblocks.org/
(Code::Blocks can be downloaded packaged with a reasonably up to date MinGW compiler.)

You can read about the problems with DevC++ here:
http://www.cplusplus.com/forum/articles/36896/
You'll also find various other IDE options, if Code::Blocks is not to your liking.

And just to avoid any confusion, DevC++ is not a compiler. It is an Integrated Development Environment (IDE). It combines an editor with a compiler toolset among other things. The actual compiler, which produces machine code from your source, is called MinGW (Minimalist GNU for Windows).

@LB: Looks like you ninja'd me with the link ;)
Last edited on
thanks a lot "Ather" , "L B" and "Xander314"
I am new at c++ first of all "Ather" detected the problem :)
now i m going to download other one for coding in c++.
thanks again
Topic archived. No new replies allowed.