Assume that month is an int variable whose value is 1 or 2 or 3 or 5 … or 11 or 12. Write an expression whose value is “jan” or “feb or “mar” or “apr” or “may” or “jun” or “jul” or “aug” or “sep” or “oct” or “nov” or “dec” based on the value of month. (So, if the value of month were 4 then the value of the expression would be “apr”.).

LANGUAGE: C++

CHALLENGE:

Assume that month is an int variable whose value is 1 or 2 or 3 or 5 … or 11 or 12. Write an expression whose value is “jan” or “feb or “mar” or “apr” or “may” or “jun” or “jul” or “aug” or “sep” or “oct” or “nov” or “dec” based on the value of month. (So, if the value of month were 4 then the value of the expression would be “apr”.).

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

4 Comments

  1. Arturo on March 2, 2015 at 8:00 pm

    The colon at the end of the code is not necessary.

  2. Alex on March 27, 2015 at 11:48 am

    There is just one extra “:” sign at the end. All other is good
    thanks!

  3. Leda on February 9, 2017 at 7:08 pm

    Write an expression using the conditional operator (? 🙂 that compares the value of the variable x to 5 and results in:

    x if x is greater than or equal to 5
    -x if x is less than 5

Leave a Comment

You must be logged in to post a comment.