A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Switch case in C Programming

Switch case in C Programming

Switch case in C Programming:

Program:-





#include    
#include    
int main()
{
 char i;
 scanf("%c",&i);
 switch(i)
 {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
  printf("It is vowel");
  break;
  default:
  printf("It is not a Vowel");
 }
 getch();
}


 
Sample output:

Program2:-





#include    
#include    
int main()
{
 int y,m,d;
 printf("Enter the year");
 scanf("%d",&y);
 printf("Enter the month");
 scanf("%d",&m);
 switch(m)
 {
  case 1:
  case 3:
  case 5:
  case 7:
  case 8:
  case 10:
  case 12:
  d=31;
  printf("%d",d);
  break;
  case 4:
  case 6:
  case 9:
  case 11:
  d=30;
  printf("%d",d);
  break;
  case 2:
  if(y%4==0)
  {
   d=29;
   printf("leap yr");
   printf("%d",d);
  }
  else
  {
   d=28;
   printf("not a leap yr");
   printf("%d",d);
  }
  break;
  default:
   printf("Wrong choice");
  break;
   printf("%d",d);
  }
 getch();
}


 

LEARN TUTORIALS

.

.