Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6253143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:56:10+00:00 2026-05-24T13:56:10+00:00

enum ENU{YES=0,NO,DONTKNOW}; void func(ENU e) { int n; cout<<1+1=; cin >> n; if(n==2) cout<<e.YES;

  • 0
enum ENU{YES=0,NO,DONTKNOW};

void func(ENU e)
{
   int n;
   cout<<"1+1=";
   cin >> n;
   if(n==2)
     cout<<e.YES;
   else 
     cout<<e.NO;
   if(ischar(n))   
     cout<<e.DONTKNOW;
}

The error is always displayed. Because my program is too small and poor formed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:56:11+00:00Added an answer on May 24, 2026 at 1:56 pm

    You probably want something like this:

        enum ENU {YES=0,NO,DONTKNOW};
        void func()
        {
           int n;
           cout<<"1+1=";
           cin >> n;
    
           if(ischar(n))   
             cout<< DONTKNOW;
           else if(n==2)
             cout<< YES;
           else 
             cout<< NO;
        }
    

    There’s no point in your example in passing the parameter ENU to func().
    Also, you must test for ischar() first, to avoid entering any of the two other tests if it’s not necessary.
    Note that outputing your enum value with “cout<< YES;” for example, will not write “YES” to the console, but only its numeric value “0”.

    And a version which demonstrate the use of enum a little better:

    void func()
    {
       int n;
       cout<<"1+1=";
       cin >> n;
       ENU e = YES;
    
       if(ischar(n))   
         e = DONTKNOW;
       else if(n==2)
         e = YES;
       else 
         e = NO;
    
        cout << e << endl;
    }
    

    Remark: ischar() is probably not working as you would expect, as you’re not giving it a character code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

enum Answer : int { Yes = 1, No = 2 } Answer answer
enum options {Yes,No}; class A{ int i; string str; options opt; }; int main{
My enum consists of the following values: private enum PublishStatusses{ NotCompleted, Completed, Error };
public enum A { A(1); private A(int i){ } private A(){ super(); // compile
An enum variable, anyone know if it is always defaulting to the first element?
public enum MyUnits { MILLSECONDS(1, milliseconds), SECONDS(2, seconds),MINUTES(3,minutes), HOURS(4, hours); private MyUnits(int quantity, String
enum icecream { vanilla(100), strawberry(20); int price; icecream(int i) { price = i; }
enum ArgPos { P1 = 1, P2 = 2, P3 = 3 }; void
public enum sEnum { zero = 0, one = 1 } public int x;
enum MyEnum { A( 1, 2, 3, 4), B(1, 2), C(4, 5, 8, 8,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.