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

  • SEARCH
  • Home
  • 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 7608959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:03:10+00:00 2026-05-31T01:03:10+00:00

I am a bit confused about the following if_even function. How is the return

  • 0

I am a bit confused about the following if_even function. How is the return type FLAGS? This seems strange – isn’t an enum just a list of multiple integers to be used like #define‘s ?

enum flag_o_e {EVEN, ODD};
enum flag_o_e test1;
typedef enum flag_o_e FLAGS;

FLAGS if_even(int n);

main()
{
  int x;
  FLAGS test2; 

  printf("input an integer: ");  scanf("%d", &x);
  test2 =  if_even(x); 
  if (test2 == EVEN)
    printf("test succeeded (%d is even)\n", x);
  else
    printf("test failed (%d is odd)\n", x);system("pause");
}

FLAGS if_even(int  n)
{
  if (n%2)
    return ODD;
  else
    return EVEN;

   }

I appreciate any tips or advice.

  • 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-31T01:03:11+00:00Added an answer on May 31, 2026 at 1:03 am

    Yes the enum declared at declared at the very top enum flag_o_e {EVEN, ODD}; is just the same as doing

    #define EVEN 0
    #define ODD 1
    typedef int flag_o_e;
    

    Then there is a further typedef to use FLAGS in place of flag_o_e so its essentially:

    #define EVEN 0
    #define ODD 1
    typedef int FLAGS;
    

    So when if_even() executes return EVEN; its actually returning an int, and similarly the comparison of the result if (test2 == EVEN) is comparing the result (which is really an int) with EVEN, which is also an int.

    typedef’s can get a little confusing, but its just a technique to rename a type (such as int, or ‘struct foo’) to something more readable and contextual.

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

Sidebar

Related Questions

This may seem silly, but I'm a bit confused about the following code: public
I'm a bit confused about the following. Given this class: public class SomeClassToBeCasted {
I am bit confused about ADO.Net Data Services. Is it just meant for creating
I am a bit confused about this. If you're building a distributed application, which
I'm working through NerdDinner and I'm a bit confused about the following section... First
Hello i'm selfstudying C and i'm a bit confused about the following code since
My question is the following. I'm a bit confused about the path of resources
My question is the following. I'm a bit confused about the path of resources
I'm a bit confused about passing the JavaScript variables by reference. Take the following
I'm a bit confused about the following code. If I comment out the second

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.