Professional Documents
Culture Documents
Scientific Calculator
Submitted To:
Mam Maryam
Submitted By:
M.TULAIB(BCSM-F16-129)
FARHAN ALI(BCSM-F16-134)
Hafiz Mubeen Ahmad(BCSM-F16-515)
Section:
Summer BSCS-A
SUPERIOR UNIVERSITY LAHORE COMPUTER SCIENCE
DEPARTMENT
Project scope:
The scope of this project is very vast because scientific
calculators are most important factor in the modern times and almost
used in multiple fields of our daily lives. It is the new step in the flowing
stream of technology and advancements. It solves most complex
problems within few seconds. As the world is changing on a rapid rate.
So, no one can stuck to the previous time. In those times simple
calculators we're enough to solve the problems. Now only scientific
calculators are the most authentic devices that can be used in every
filed from science to mathematics. So its value is increasing day by day
due to its validity. Anyone can easily calculate complex values by using
this calculator and bring ease in their lives. Problems like sin, cos, tan
and etc can be solved by this calculator very easily and quickly.
Introduction:
Scientific calculators are advanced form of calculators
used to solve various problems at the same time. It is multi-tasking. It is
used on higher level like science, engineering, medical and
mathematics. If a person is doing some projects in mathematics or
science than he can solve this problem only through scientific
calculators. Versatility of scientific calculators makes it more unique
than the simple calculators. It includes various functions like statistics,
solving complex and tangible problems. It is used in different fields like
physics, chemistry, astronomy and science as well. It is most beneficial
on higher level for researchers and University and college students.
Regular Expression, NFA and DFA:
Lexical Code:
%{
#include<stdio.h>
#include<math.h>
float a,b,c,d;
int operator=0,i;
%}
digit [0-9]+|([0-9]*\.[0-9]+)
add "+"
sub "-"
mul "*"
div "/"
pow "^"
en \n
s "sin"
c "cos"
t "tan"
sq "sqrt"
log "log"
lgn "lgn"
sec "sec"
cot "cot"
cosec "cosec"
%%
{digit} {dig();}
{add} {operator=1;}
{sub} {operator=2;}
{mul} {operator=3;}
{div} {operator=4;}
{pow} {operator=5;}
printf("\n");}
{s} {operator=6;}
{c} {operator=7;}
{t} {operator=8;}
{sq} {operator=9;}
{log} {operator=10;}
{lgn} {operator=11;}
{sec} {operator=12;}
{cot} {operator=13;}
{cosec} {operator=14;}
%%
dig()
if(operator==0)
a=atof(yytext);
else
b=atof(yytext);
switch(operator)
case 1:
a=a+b;
break;
case 2:
a=a-b;
break;
case 3:
a=a*b;
break;
case 4:
a=a/b;
break;
case 5:
for(i=a;b>1;b--)
a=a*i;
break;
case 6:
a=sin(b);
break;
case 7:
a=cos(b);
break;
case 8:
a=tan(b);
break;
case 9:
a=sqrt(b);
break;
case 10:
a=log10(b);
break;
break;
case 12:
c=cos(b);
a=1/c;
break;
case 14:
c=sin(b);
a=1/c;
break;
case 13:
c=cos(b);
d=sin(b);
a=c/d;
break;
operator=0;
int yywrap()
return 1;
int main()
yytext;
yylex();
return 0;
}
Operator Precedence:
CFG’s:
Convert Left recursive to right recursive:
First and follow:
Parsing Table:
Stack Implementation, Bottom up Parser:
Semantic Analysis: