Calculator program in Pascal

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

  1. 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
    23
    1. but how do we do that in Lazarus Pascal?????
      0
    2. Thank you
      0
  2. Hi Bocandé,

    Send us your code, and we'll correct it for you.

    marvinrouge
    2
    1. 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
      2
      1. Hello
        I am a student at the University of Skikda, looking for a calculus program
        Thank you
        0
      2. Salut, pourquoi ce n'est pas valide ? Je suis étudiant en deuxième année d'informatique à Skikda, j'ai besoin d'aide pour faire ce TP avec un mémoire M1 et M2.
        0
      3. @aminesoftSalut, moi aussi j'ai besoin de ce TP, aide-moi mon email est meriem.fifi@yahoo.fr.
        0
      4. @fifiHello
        I am a student at the University of Skikda, a second-year computer science student medlamine21@hotmail.fr
        0
      5. نقولكم حاجة راني بوجحم إلي ما تقدروش تلعبو عليها. مريم مهندسة دولة في الإعلام الآلي، كملت دراستي الجامعية.
        0
    2. 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
      2
      1. 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 :/
        0