SWITCH CASE / SELECT CASE

These statements are used with the replacement of if-else and these statements are used when we have multiple options or choices. These choices can be limited and when we use switch case we can use only integer or character variable as expression.


#include <stdio.h>

void main()

{

int,ch qty;

long tb,dis,nb;

clrscr();

printf("1.BPL\n2.Onida\n3.Sony\n4.Samsung\n5.LG\n");

printf("\nEnter Your Choice: ");

fflush(stdin);

scanf("%d",&ch);

printf("Enter Qty: ");

scanf("%d",&qty);

switch(ch)

{

case 1:tb=(long)qty*10000;

printf("\nBPL is %ld",tb);

break;

case 2:tb=(long)qty*12000;

printf("\nOnida is %ld",tb);

break;

case 3:tb=(long)qty*11500;

printf("\nSony is %ld ",tb);


break;

case 4:tb=(long)qty*11000;

printf("\nSamsung is %ld ",tb);

break;

case 5:tb=(long)qty*13000;

printf("\nLG is %ld ",tb);

break;

default:

printf("Wrong Choice...");

}

dis=(tb*10)/100;

nb=tb-dis;

printf("\nDiscount is %ld",dis);

printf("\nNet bill is %ld",nb);

getch();

}