14 Feb 2014

Designing Caluclator using C

Problem:
Design a caluclator using C

Code:

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d;
clrscr();
printf("Menu\n1.Addition\n2.Substraction\n3.Multiplication\n4.Division\n5.exit\nEnter your choice");
scanf("%d",&c);
switch(c)
{
case 1:
printf("\nEnter the value of 1st  number");
scanf("%d",&a);
printf("\nEnter the value of 2nd  number");
scanf("%d",&b);
d=a+b;
printf("Reullt after Addition=%d",d);
break;
case 2:
printf("\nEnter the value of 1st  number");
scanf("%d",&a);
printf("\nEnter the value of 2nd  number");
scanf("%d",&b);
d=a-b;
printf("Reullt after Substraction=%d",d);
break;
case 3:
printf("\nEnter the value of 1st  number");
scanf("%d",&a);
printf("\nEnter the value of 2nd  number");
scanf("%d",&b);
d=a*b;
printf("Reullt after Multiplication=%d",d);
break;
case 4:
printf("\nEnter the value of 1st  number");
scanf("%d",&a);
printf("\nEnter the value of 2nd  number");
scanf("%d",&b);
d=a/b;
printf("Reullt after Division=%d",d);
break;
case 5:
exit(0);
default:
printf("\nWrong Choice");
}
}

No comments:

Post a Comment