Sunday, 21 January 2018

Program For Switch Case | Example for Switch Case Program


Program For Switch Case
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
main()
{
int gd=DETECT,gm;
int l,m,n,d,e;
clrscr();
initgraph(&gd,&gm,".");
gotoxy(12,28);
printf("\n\n\n\n\n\n");
printf("\t\t\t");


printf("*****************************");
printf("\t\t\t");
printf("\n\n");
printf("\t\t\tE N T E R  T H E  O P T I O N\n");
printf("\t\t\t");
printf("\n\t\t\t\******************************");
printf("\n\n");
printf("\t\t\t\t    1.ADD\n");
printf("\t\t\t\t    2.SUB\n");
printf("\t\t\t\t    3.DIV\n");
printf("\t\t\t\t    4.MUL\n");
printf("\t\t\t\t    5.EXIT\n");
rectangle(135,75,490,280);
printf("\n");
printf("\t\t\t E N T E R  T H E   V A L U E S:");
scanf("%d",&n);
clrscr();
printf("\n\n\n\n\n\n");
printf("\t\t       E N T E R  T H E  V A L U E :L , M :");
printf("\n");
scanf("%d %d",&l,&m);
gotoxy(12,28);
rectangle(135,75,490,280);
clrscr();

switch(n)
{
case 1:
d=l+m;
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ A D D T I O N = % d",d);
printf("\n\n       P R O G R A M    H A S  E N D  F O R   T H I S    O P E R A C T I O N");
break;
case 2:
d=l-m;
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ S U B T R A C T = % d",d);
printf("\n\n");
printf("\n       P R O G R A M   H A S  E N D  F O R  T H I S    O P E R A C T I O N");
break;
case 3:
d=l/m;
e=l%m;
printf("\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ Q U E F I C E N T = % d\n",d);
printf("\n");
printf("\t\t\t\t\ R E M I N D E R = % d",e);
printf("\n\n");
printf("\tP R O G R A M   H A S   E N D  F O R  T H I S  O P E R A C T I O N");
break;
case 4:
d=l*m;
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\ M U L T I P L A Y = % d",d);
printf("\n\n");
printf("    P R O G R A M    H A S    E N D    F O R   T H I S   O P E R A C T I O N");
break;
case 5:
exit();
default:
break;
}
getch();
}

Related Posts:

  • Pointers And StructuresPointers And StructuresWe know that the name of an array stands for the address of its zeroth element.The samething is true of the names of arrays of structure variables.Suppose product is an array variable of structtype.The … Read More
  • Introduction to File ManagementIntroduction to File ManagementThere are numerous library functions available for I/O .These are categorized into three:  a)Console I/O Functions     Functions to receive input from keyboard and write outp… Read More
  • Add of Two numbers#include<stdio.h>#include<conio.h>#define add 20main(){ int a,b; clrscr(); printf("enter the value:"); scanf("%d",&a); b=add+a; printf("the result is %d",b); getch();}�… Read More
  • Arrays With In The StructuresArrays With In The Structures C permits the use of arrays as structure members.we can use single or multidimensional arrays of type int or float.Ex:   struct marks      {      &nbs… Read More
  • Graphic Program#include<stdio.h>#include<conio.h>#include<graphics.h>main(){ int r=12,c=80; clrscr(); while(!kbhit()) { gotoxy(c,r); textcolor(c+BLINK+3+7); cprintf(".......ANIL KUMAR......."); c--; if(c==1) { c=80… Read More

0 comments:

Post a Comment