calender

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sujatap
    New Member
    • Nov 2008
    • 1

    #1

    calender

    hello..
    i have a problem in a calender coding..for creating a function for the odd days in a month,,a book has specified the following syntax..
    odddaymonth(int mm, char leapyear)
    {
    switch(mm)
    {
    case 1:
    return 0;

    case 2:
    return 3;

    case 3:
    case 11:
    return leapyear?4:3;

    case 4:
    case 7:
    return leapyear?0:6;

    case 5:
    return leapyear?2:1;

    case 6:
    return leapyear?5:4;

    case 8:
    return leapyear?3:2;

    case 9:
    case 12:
    return leapyear?6:5;

    case 10:
    return leapyear?1:0;
    }
    return 0;
    }

    can anyone explain me the syntax.. please help me out....

    sujata
  • oler1s
    Recognized Expert Contributor
    • Aug 2007
    • 671

    #2
    If you have a book, does it not explain the syntax to you. Look up the relevant section on switch statements.

    Comment

    • donbock
      Recognized Expert Top Contributor
      • Mar 2008
      • 2427

      #3
      Are you referring to statements of the form ...
      return leapyear?1:0;

      This is a conditional expression, written using the ternary operator "?:".
      You can google "conditiona l expression" and/or "ternary operator".

      Comment

      Working...