CALCULATOR PROGRAM USING C LANGUAGE ( using switch case )

CALCULATOR PROGRAM USING C LANGUAGE ( using switch case )
#include<stdio.h>
#include<conio.h>
void main()
{
char choice;
int a,b;
clrscr();
printf("enter two numbers\n");
scanf("%d%d",&a,&b);
printf("enter your choice\n");
printf(" + addition \n - subtraction\n");
printf("* multiplication \n  / division\n");

scanf("%c",&choice);
switch(choice)
{
case '+' :
c=a+b;
  printf("%d",c);
  break;
case '-' :
  c=a-b;
printf("%d",c);
  break;
case '*' :
c=a*b;
  printf("%d",c);
  break;
case '/' :
  c=a/b;
printf("%d",c);
  break;
default: printf("invalid choice");
}
getch();
}

No comments:

Post a Comment