Calculator program in Pascal
bocandé
Posted messages
4
Status
Member
-
Lion -
Lion -
Hello brotherhood, I'm writing to you to submit a problem, that of being able to create a calculator in Pascal. I can't execute 2 consecutive calculations without restarting the application. What should I do?
5 answers
-
program calculator;
uses WinCrt; var a,b,r:real; x:char; function add(var a,b: real):real; begin r:=a+b; end; function sub(var a,b: real):real; begin r:=a-b; end; function mul(var a,b: real):real; begin r:=a*b; end; function divis(var a,b: real):real; begin r:=a/b; end; begin writeln('calculator PASCAL'); readln(a); readln(x); readln(b); case x of '+': add(a,b); '-': sub(a,b); '*': mul(a,b); '/': divis(a,b); end; writeln(r); end.
from Mehdi Skikda Algeria in 2nd year computer science LMD -
-
this program is not valid because
1_the calculation is done only once
2_this program doesn't recognize the '=' ok;
give me your msn I want to help you -
Hello,
I noticed 2 errors in your program
1- The first is that in the divis function, you need to first check if b is different from zero
2- The second is that you need to look into this ^_^ to understand well
https://pascal.developpez.com/cours/ptrau/?page=page_13#LXIII-D
Your problem lies in the 2 levels of function calls + the result returned by each function in your program
Here is the solution https://pascal.developpez.com/cours/ptrau/?page=page_13#LXIII-D -
Bonjour, s'il vous plaît, si vous avez fait ce programme, vous ne pourriez pas me le passer parce que j'en ai vraiment besoin, il compte comme contrôle et je dois le rendre dans deux jours :/