Thursday, 19 December 2019

Calculator design in C

#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,sum,ch;
     printf("case 1 for addition\n");
printf("case 2 for subtraction\n");
printf("case 3 for multiplication\n");
printf("case 4 for division\n");
printf("enter your choice\n");
scanf("%d",&ch);
switch(ch)
  {
    case 1:
printf("enter two number\n");
    scanf("%d%d",&a,&b);
    sum=a+b;
    printf(" the addition is %d\n",sum);
    break;
    case 2:   
printf("enter two number\n");
scanf("%d%d",&a,&b);
c=a-b;
printf(" the subtraction is %d\n",c);
break;
  case 3:
printf(" enter two number\n");
scanf("%d%d",&a,&b);
c=a*b;
printf(" the multiplication is %d\n",c);
break;
  case 4:
printf("enter two number\n");
scanf("%d%d",&a,&b);
c=a/b;
printf("the division is %d\n",c);
break;
default:
    printf("wrong choice\n");
  }
  getch();
  return 0;
}

No comments:

Post a Comment

Convey your thoughts to authors.