Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Plain Text by Bala ( 11 years ago )
#include<conio.h>
#include<stdio.h>
#include<math.h>

void showdialog(int,int,char,double);

void input(int *,int *);

void main()
{
 int op1,op2,i;
 double res,op;
 char ch;
 clrscr();

 showdialog(0,0,' ',0);

 again:
 printf("Operend:");
 fflush(stdin);
 scanf("%c",&ch;);

 switch(ch)
 {
  case '+':

  input(&op1;,&op2;);
  res=op1+op2;
  showdialog(op1,op2,ch,res);
  goto again;

  case '-':
  input(&op1;,&op2;);
  res=op1-op2;
  showdialog(op1,op2,ch,res);
  goto again;

  case '*':
  input(&op1;,&op2;);
  res=op1*op2;
  showdialog(op1,op2,ch,res);
  goto again;

  case '/':
  input(&op1;,&op2;);
  res=(double)op1/op2;
  showdialog(op1,op2,ch,res);
  goto again;

  case 'r':
  case 'R':
  printf("Input:");
  scanf("%d",&op2;);
  res=sqrt((double)op2);
  showdialog(0,op2,251,res);
  goto again;

  case 'i':
  case 'I':
  printf("Input:");
  scanf("%d",&op2;);
  res=(double)1/op2;
  showdialog(1,op2,'/',res);
  goto again;

  case '%':
  input(&op1;,&op2;);
  res=((double)op1/op2)*100;
  showdialog(op1,op2,ch,res);
  goto again;

  case 's':
  case 'S':
  printf("Input:\n");
  scanf("%lf",&op;);
  res=sin(op);
  showdialog(0,(int)op,' ',res);
  goto again;

  case 'c':
  case 'C':
  printf("Input:\n");
  scanf("%lf",&op;);
  res=cos(op);
  showdialog(0,(int)op,' ',res);
  goto again;

  case 't':
  case 'T':
  printf("Input:\n");
  scanf("%lf",&op;);
  res=tan(op);
  showdialog(0,(int)op,' ',res);
  goto again;

  case 'f':
  case 'F':
  printf("Input:\n");
  scanf("%d",&op2;);
  res=1;
  for(i=op2;i>=1;i--)
   res*=i;

  showdialog(0,op2,'!',res);
  goto again;


      /*

  case 'c':
  case 'C':
  clrscr();
  showdialog(0,0,' ',0);
  goto again;  */

  case 'e':
  case 'E':
  break;

  default:

  printf("Invalid Option.");
  getch();
  clrscr();
  showdialog(0,0,' ',0);
  goto again;

 }
}

void input(int *oper1,int *oper2)
{
 printf("Input1:");
 scanf("%d",oper1);

 printf("Input2:");
 scanf("%d",oper2);

}

void showdialog(int oper1,int oper2,char cha,double result)
{
 clrscr();
 printf("      Scientific Calculator     \n");
 printf("-----------------------------------------------------\n");
 printf("       %d %c %d    \n",oper1,cha,oper2);
 printf("       = %4lf      \n",result);
 printf("-----------------------------------------------------\n");
 printf("|     |  inv | ln  |  (  |  )   |<- | E | C |  |  (r) \n",241,251);
 printf("| int | sinh | sin | x^2 |  n!  | 7 | 8 | 9 | / | % \n");
 printf("| dms | cosh | cos | x^y | y%cx  | 4 | 5 | 6 | * | 1/x (i)\n",251);
 printf("|  pi | tanh | tan | x^3 | 3%cx  | 1 | 2 | 3 | - | =\n",251);
 printf("| F-E | Exp  | Mod | log | 10^x |   0   | . | + |  \n");
 printf("-----------------------------------------------------\n");
}

 

Revise this Paste

Your Name: Code Language: