Solved

progx

Posted on 1997-03-11
1
186 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
send click   without cursor 6 375
help with delphi code 6 481
WebCam and Delphi 2 2,686
1 paragraph C code to translate into Delphi code 3 232
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

829 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