Program 1
#include
#include
#include
void main()
{
char ch;
clrscr();
          printf(" Enter any
letter\n");
          ch=getchar();
          switch(ch)
          {
          case ‘a’;
          case ‘e’;
          case ‘i’;
          case ‘o’;
          case ‘u’;
          printf("\n Given letter is vowel
letter");
          break;
          default:
          printf("Given letter is not vowel
letter");
          }
getch();
}
Output
          Enter
letter
          S
          Given letter is not a vowel letter
Program 2
#include
#include
void main()
{
int days;
clrscr();
          printf("Enter a
number\n");
          scanf("%d",&days);
          switch(days)
          {
case 1:
printf("Sunday");
break;
case 2:
printf("Monday");
break;
case 3:
printf("Tuesday");
break;
case 4:
printf("Wednesday");
break;
case 5:
printf("Thursday");
break;
case 6:
printf("Friday");
break;
case 7:
printf("Saturday");
break;
default:
printf("Invalid
choice");
}
getch();
}
Output
          Enter
a number
          6
          Friday
Program 3
#include
#include
void main()
{
int choice,x,y;
clrscr();
          printf("\n\t\t\t Calculator Program");
          printf("************************************");
          printf("Enter 2 number\n");
          scanf("%d%d",&x,&y);
          printf("\n 1. Addition of 2
nums");
          printf("\n 2. Subtraction of 2
nums");
          printf("\n 3. Multiplication of 2
nums");
          printf("\n 4. Divition of 2
nums");
          printf("\n Enter your choice
from(1to 4) ");
          scanf("%d",&choice);
          switch(choice);
          {
          case 1:
          printf("%d+%d  is = %d",x,y(x+y));
          break;
          case 2:
          printf(" %d - %d is =
%d",x,y(x-y));
          break;
          case 3:
          printf(" %d * %d is =
%d",x,y(x*y));
          break;
          case 4:
          printf("%d / %d is =
%d",x,y(x/y));
          break;
          default:
          printf(" Invalid input enter
between ( 1 to 4) only");
          }
getch();
}
Output
           Calculator Program
          ************************************
          Enter
2 number
          20
          5
1.    
Addition of 2 nums
2.    
Subtraction of  2 nums
3.    
Multiplication of 2
nums
4.    
Divition of 2 nums
Enter your choice from ( 1 to 4)
3
20*5=100
 
No comments:
Post a Comment