Solved

progx

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now