• Advertisement
Sign in to follow this  

cout error in this small program

This topic is 4217 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

could anyone please help me find the error here , compiler said "cout undeclared"

// ex 6 page 64

#include <iostream>

void DisplayTime(int,int);

int main()
{
  using namespace std;
  
  int hours;
  int minutes;
  cout<< " Please enter hours: "<<endl;
  cin >> hours;
  cout << " Please enter minutes: ";
  cin >> minutes;
  
 DisplayTime(hours,minutes);
  
  return 0;
}  
  
void DisplayTime(int h,int m)
{
cout << " Time: "<<h<<":"<<m;
}


Share this post


Link to post
Share on other sites
Advertisement
When you put using namespace std inside the main() function it only applies to the name lookups inside main(). If you want to apply it to the whole file you should place it before your function definitions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement