[ create a new paste ] login | about

Link: http://codepad.org/p3uFTLyn    [ raw code | output | fork ]

appunti2 - C, pasted on May 1:
#include <stdio.h>
int main (void)
{
    int anno;
    int mese;
    int giorni;
    anno = 2013;
    mese = 2;

    switch (mese)
      {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            giorni = 31;
            break;
        case 4:
        case 6:
        case 9:
        case 11:
            giorni = 30;
            break;
        case 2:
            if (((anno % 4 == 0) && !(anno % 100 == 0))
                || (anno % 400 == 0))
              {
                giorni = 29;
              }
            else
              {
                giorni = 28;
              }
            break;
      }
    printf ("Il mese %d dell'anno %d ha %d giorni.\n",
            mese, anno, giorni);
    getchar ();
    return 0;
}


Output:
1
Il mese 2 dell'anno 2013 ha 28 giorni.


Create a new paste based on this one


Comments: