Solved

progx

Posted on 1997-03-11
1
184 Views
Last Modified: 2010-04-16
Hello,
     please, asap, provide me with any possible ideas, hints or ,in detail,solutions to the following program:-

* Write a pascal program to input two real numbers and give the user the choice to adding, subtracting, multiplying or dividing these numbers. Perform the appropriate calculation and display the result. Your program should trap any attempt to divide by zero.

We have covered the For,repeat,While,and case statements, and arrays.      
0
Comment
Question by:hmalkuz1
1 Comment
 
LVL 1

Accepted Solution

by:
chump earned 20 total points
ID: 1215240
program Calc;

var real1, real2 : real;
    choice       : string;

begin

  write("Number 1: ");
  readln(real1);
  write("Number 2: ");
  readln(real2);

  write("Choice: ");
  readln(choice);

  write("Result : ");
 
  case choice[1] of
   '+' : write(real1 + real2);
   '-' : write(real1 - real2);
   '*' : write(real1 * real2);
   '/' : if real2 = 0 then write("<divide by zero>")
                      else write(real1 / real2);
  end;
 
  writeln;

end.

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question