Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# input random elements to an array

Posted on 1998-08-06
Medium Priority
240 Views
If I have an array or an type of all "char" ,  how can I  input a random result from that array into a smallar array, f.x.  array [1..5] of Char;
, or better, a few arrays of that same type.
0
Question by:gudbgud
[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
• 2

Author Comment

ID: 1217273
Edited text of question
0

Author Comment

ID: 1217274
Edited text of question
0

LVL 2

Accepted Solution

vx earned 100 total points
ID: 1217275
I coded a little program for you; I think it does what you mean:

Var FirstArray: Array[1..100] of Char;          { The whole array }
SecArray:   Array[1..5] of Char;            { The new array }
Counter:    Integer;                        { A random number }

Begin
Repeat
Randomize;                                  { Initialize random sequence }
Counter := Random(100)+1;                   { Create a random number and add one to that }
{ Random generates a number from 0<=x<100 }
{ The array shouldn't be addresses with 0, so add one }
SecArray := FirstArray[Counter];            { Copy a number from the first array to the second }
Until KeyPressed;
End.
0

## Featured Post

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Check out what's been happening in the Experts Exchange community.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
###### Suggested Courses
Course of the Month7 days, 12 hours left to enroll