Solved

Input validation in Pascal

Posted on 2002-05-13
3
744 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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
groupSumClump challenge 9 137
firstswap challenge 20 84
Base1 Encode/Decode 3 85
Identify two keyboard codes and how to enter them 9 68
This is an explanation of a simple data model to help parse a JSON feed
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

713 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