Solved

Input validation in Pascal

Posted on 2002-05-13
3
748 Views
Last Modified: 2008-02-01
Dear Programmers

Could you please supply me with a piece of code in Pascal (Turbo 7) to answer the following problem:

Declare an array N which contains 30 cells of integer type and prompt the user to read in 30 integers between 0 and hundred.

Validity of input between 0 and 100 is important.
0
Comment
Question by:cybernursery
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 7006592
Homework?
0
 

Accepted Solution

by:
eddiejr earned 100 total points
ID: 7007155
program FillArray;

var
  I: byte;
  N: array[1..30]of integer;
  Value: integer;

begin
  writeln('This program fills an array of 30 elements with values between 0..100');
  for I := 1 to 30 do begin
    writeln('Enter a value (0..100) for element ', I, ' : ');
    repeat
      readln(Value);
    until (Value >= 0) and (Value <= 100);
  end;
end.
0
 

Author Comment

by:cybernursery
ID: 7009526
First of all thanks to eddiejr,   I was aware of the code but I wanted to be sure that I answered correctly.  This was my first time.  Next time I paste the code and ask for your comments.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

737 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