HTML Tutorial || Networking Assignment || Computer Full Forms || Ms-Office Shortcut Keys || Ms-Office Notes || Number System Notes || Internet Assignment
JavaScript Tutorial || CSS Tutorial || Operating System Notes || History of Computer Assignment || Netwoking Notes || Computer Fundamentals Notes

C program to Create Simple Calculator Using Switch case ?


Q:- Write a C program to Create Simple Calculator Using Switch case ?
      Input
        #include<stdio.h>
        #include<conio.h>
        main()
   {
int a,b,c=0,d=0;
clrscr();
printf(“Enter Two Number =”);
scanf(“%d%d”,&a,&b);
printf(“\n Operation Choices\n”);
printf(“\n Press 1 for Sum”);
printf(“\n Press 2 for Subtraction”);
printf(“\n Press 3 for Multiplication”);
printf(“\n Press 4 for Exit”);
scanf(“%d”,&c);
switch(c)
{
case 1: d=a+b;
break;
case 2: d=a-b;
break;
case 3: d=a*b;
break;
case 4: exit();
break;
default : printf(“Invalid Input!!!!!!!!”);
}
printf(“\n\n Result = %d”,d);
getch();
    }


Output

Enter Two Numbers = 10
20
Operation Choices 1
Result = 30


Comments