5 answers
program calculator;
from Mehdi Skikda Algeria in 2nd year computer science LMD
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
RIHEM
but how do we do that in Lazarus Pascal?????
Lion
Thank you
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
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
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