Thread: Code showing error

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    73

    Code showing error

    In the time of compiling, this code is giving some error -

    Code:
    void printNumberIfEven(int num)
    
    {
    
    if (num % 2 == 1) 
    {
    cout << "odd number" << endl;
    return;
    }
    cout << "number is " << num << endl;
    
    }
    
    int main()
    
    {
    int x = 4;
    printNumberIfEven(x);
    // number is 3
    int y = 5;
    printNumberIfEven(y);
    // odd number
    }

    Like -

    error C2065: 'cout' : undeclared identifier
    error C2297: '<<' : illegal, right operand has type 'char [11]'
    error C2065: 'endl' : undeclared identifier
    error C2297: '<<' : illegal, right operand has type 'char [11]'

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    73
    Any help for that ?

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    What include file have you included? How are you scoping the std namespace?

    Jim

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    73
    Ohh thanks . Now,I get it

  5. #5
    Registered User
    Join Date
    Jan 2012
    Posts
    11
    You forget that the library where the program?
    Sorry my english is very bad.

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    73
    cauberong09 @ it is solved now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GDB showing memory error
    By SasDutta in forum C Programming
    Replies: 3
    Last Post: 12-17-2010, 01:51 PM
  2. Menu showing twice?
    By bconnor in forum C Programming
    Replies: 4
    Last Post: 10-17-2006, 05:58 AM
  3. programs are not showing!
    By Buckz in forum C++ Programming
    Replies: 19
    Last Post: 12-29-2005, 06:58 PM
  4. icon not showing
    By xlnk in forum Windows Programming
    Replies: 2
    Last Post: 02-27-2004, 06:36 PM
  5. Pic not showing up
    By Hunter2 in forum Game Programming
    Replies: 14
    Last Post: 11-13-2002, 01:19 PM