Advertisement
Igor2909

es2.cc

Dec 4th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. main()
  5. {
  6.     printf("Inserisci il numero del mese: ");
  7.     int n;
  8.     scanf("%d", &n);
  9.     switch(n){
  10.         case 1: case 3: case 5: case 7: case 8: case 10: case 12:
  11.             printf("Il mese ha 31 giorni.");
  12.             break;
  13.         case 4: case 6: case 9: case 11:
  14.             printf("Il mese ha 30 giorni.");
  15.         case 2:
  16.             {
  17.                 int b;
  18.                 printf("L'anno è bisestile? \n1 per si\' \n2 per no\n");
  19.                 scanf("%d", &b);
  20.                 if(b == 1){
  21.                     printf("Il mese ha 29 giorni.");
  22.                 } else {
  23.                     printf("Il mese ha 28 giorni.");
  24.                 }
  25.                 break;
  26.             }
  27.         default:
  28.             printf("Numero del mese non esistente!");
  29.            
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement