/*…Hey Guy’s this is a program to illustrate the use of switch statement..*/
#include<stdio.h>
#include<conio.h>
void main()
#include<conio.h>
void main()
/*…Main Function Start’s..*/
{
float num1 , num2 , num3;
int ch;
clrscr();
printf(“ENTER THE CHOICE YOU WANT TO PERFORM FROM BELOW OPTIONS\n”);
printf(” 1.) ADDITION\n”);
printf(” 2.) SUBTRACTION\n”);
printf(” 3.) MULTIPLICATION\n”);
printf(” 4.) DIVISION\n”);
printf(” 5.) FOR EXIT\n”);
printf(“CHOICE IS—”);
scanf(” %d”,&ch);
{
float num1 , num2 , num3;
int ch;
clrscr();
printf(“ENTER THE CHOICE YOU WANT TO PERFORM FROM BELOW OPTIONS\n”);
printf(” 1.) ADDITION\n”);
printf(” 2.) SUBTRACTION\n”);
printf(” 3.) MULTIPLICATION\n”);
printf(” 4.) DIVISION\n”);
printf(” 5.) FOR EXIT\n”);
printf(“CHOICE IS—”);
scanf(” %d”,&ch);
switch(ch) /*…Switch case Start’s..*/
{
case 1:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 + num2;
printf(“\nADDITION==%f”,num3);
break;
case 2:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 – num2;
printf(“\nSUBTRACTION==%f”,num3);
break;
case 3:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 * num2;
printf(“\nMULTIPLICATION==%f”,num3);
break;
case 4:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 / num2;
printf(“\nDIVISION==%f”,num3);
break;
case 5:
printf(“YOU HAVE ENTERED A WRONG CHOICE\n”);
break;
}
{
case 1:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 + num2;
printf(“\nADDITION==%f”,num3);
break;
case 2:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 – num2;
printf(“\nSUBTRACTION==%f”,num3);
break;
case 3:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 * num2;
printf(“\nMULTIPLICATION==%f”,num3);
break;
case 4:
printf(“ENTER THE VALUE OF num1 AND num2\n”);
scanf(“%f\n %f”,&num1,&num2);
num3 = num1 / num2;
printf(“\nDIVISION==%f”,num3);
break;
case 5:
printf(“YOU HAVE ENTERED A WRONG CHOICE\n”);
break;
}
/*…Switch Case End’s…*/
getch();
}
getch();
}
/*….Main Function End’s….*/
THE OUTPUT IS::::::::::::::
No comments:
Post a Comment