Thread: easy if statement

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    81

    easy if statement

    How could I design an if statement to where it would return an error message if the user did not enter the values 1-31.

    Like so:
    PHP Code:
    cout << "Please enter the desired day (choose from 1-31) ";
        
    cin >> dayNum;
        if(
    dayNum!=&& dayNum!=&&dayNum !=&&...)// need to make this more simple!!!!!
        
    {
    cout << "Invalid entry\n" << endl;
            
    menu(proceed);
        }

        
    cout << "You are correct sir!\n" << endl

  2. #2
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    Code:
    if( dayNum<1 || dayNum>31 )
    {
         cout <<  "Error Tastic!"
    }
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    81
    thanks, its almost 3 AM here, my brain is a little fried

  4. #4
    Grammar Police HybridM's Avatar
    Join Date
    Jan 2003
    Posts
    355
    no problem
    Thor's self help tip:
    Maybe a neighbor is tossing leaf clippings on your lawn, looking at your woman, or harboring desires regarding your longboat. You enslave his children, set his house on fire. He shall not bother you again.

    OS: Windows XP
    Compiler: MSVC

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switch statement / default:
    By kcpilot in forum C Programming
    Replies: 4
    Last Post: 12-02-2008, 03:14 PM
  2. Using while loop for if statement.
    By Galens in forum C++ Programming
    Replies: 5
    Last Post: 10-03-2008, 03:14 PM
  3. having trouble understanding this statement
    By kes103 in forum C++ Programming
    Replies: 2
    Last Post: 10-03-2003, 09:00 AM
  4. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM