Author: Sanif S S
Site: theeduzone.blogspot.com
Email: sanifss@gmail.com#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c,m,ch,n;
printf("simple calculator\n");
do
{
printf("main menu");
printf("\n 1.addition \n 2.subtraction");
printf("\n 3.multiplication \n 4.division\n");
printf("enter your choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
c=a+b;
printf("sum=%d\n",c);
break;
case 2:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
c=a-b;
printf("difference=%d\n",c);
break;
case 3:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
c=a*b;
printf("product=%d\n",c);
break;
case 4:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
if(b==0)
{
printf("division not possible\n");
}
else
{
c=a/b;
printf("quotient=%d\n",c);
}
break;
default:
printf("invalid choice\n");
}
printf("if you wants to continue press 1 other wise press any key\n");
scanf("%d",&n);
}while(n==1);
getch();
}
{
clrscr();
int a,b,c,m,ch,n;
printf("simple calculator\n");
do
{
printf("main menu");
printf("\n 1.addition \n 2.subtraction");
printf("\n 3.multiplication \n 4.division\n");
printf("enter your choice\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
c=a+b;
printf("sum=%d\n",c);
break;
case 2:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
c=a-b;
printf("difference=%d\n",c);
break;
case 3:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
c=a*b;
printf("product=%d\n",c);
break;
case 4:
printf("enter 2 no\n");
scanf("%d %d",&a,&b);
if(b==0)
{
printf("division not possible\n");
}
else
{
c=a/b;
printf("quotient=%d\n",c);
}
break;
default:
printf("invalid choice\n");
}
printf("if you wants to continue press 1 other wise press any key\n");
scanf("%d",&n);
}while(n==1);
getch();
}
No comments:
Post a Comment