Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,396 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,109 people online right now. Registration is fast and FREE... Join Now!




Error "cout undeclared"

 
Reply to this topicStart new topic

Error "cout undeclared"

danielgm55
29 Sep, 2006 - 07:25 AM
Post #1

New D.I.C Head
*

Joined: 29 Sep, 2006
Posts: 1


My Contributions
Could someone please help me...i am using DEV-C++...i am doing an assignment for school and i keep getting "cout undeclared" (first use in function) and "cin undeclared" (first use in function) error. This is my first semester of programming and i'm kinda lost. Thank you
CODE

#include <iostream>

int main()
{
int number_of_kids;
int tickets;
int tickets_each;

cout << "How many kids each need tickets? ";
cin >> number_of_kids;
cout << "How many tickets are available?";
cin >> tickets;

tickets_each = tickets / number_of_kids

cout << "Give each kid " << tickets_each << '\n';

return 0;
}

User is offlineProfile CardPM
+Quote Post

Louisda16th
RE: Error "cout Undeclared"
29 Sep, 2006 - 07:56 AM
Post #2

 
Group Icon

Joined: 3 Aug, 2006
Posts: 1,790



Thanked: 1 times
Dream Kudos: 755
My Contributions
try this:
CODE

#include<iostream>
using namespace std;
//rest of your code here

alternatively add std:: to cout, cin, endl...
CODE

//Example:
std::cout<<"Your Text Here";

Lastly, you forgot the semicolon here:
CODE

tickets_each = tickets / number_of_kids
//change this to
tickets_each = tickets / number_of_kids;

User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Error "cout Undeclared"
29 Sep, 2006 - 09:41 AM
Post #3

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,935



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Actually, adding the namespaces or the std global specifier is not required here at all.

Your only error is that you've forgotten to add the semicolon.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:55AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month