Please help me again. I have 2 questions in this time.

Question 1.

Write a program that asks for a start and stop letter and then
produces the following:

Question one: This time create an array of 7 numbers. Fill each slot
with a randomly generated number between 1 and 10. Show the user the
7 numbers, pause the program briefly, clear the screen and then ask
the user to guess the seven numbers. Work out how many of the numbers
are correct.

First part of my answer is:


{$APPTYPE CONSOLE}

Uses SysUtils, OurCrt;
Var computer: Array [1..7] of integer;
guess: Array [1..7] of integer;
count: integer;

Begin
randomize;
For count:= 1 to 7 do
begin
computer[count]:=random(10);
writeln(computer[count]);
end;
sleep (5000);
clrscr;
For guess:= 1 to 7 do
begin
if computer[count]=guess[count] then
begin
writeln ('You''ve got right');
end;
begin
writeln ('You''ve got wrong');
sleep (5000);
clrscr;
(Now I don’t know how to going on….what it should be?)


Question 2

Write a program that asks for a start and stop letter and then
produces the following:

For start value a and stop value e:
a
ab
abc
abcd
abcde

Recommended Answers

All 3 Replies

If (you ask something) And (the answer was good) Then
   Write('Don''t forget to click the ''Mark As Solved''')
Else
   Write('Notify the others that your problem is not resolved');
{got it?}
{head or tail game....?}

:) Question 1

Program Program01;

Uses Crt;

Var TheNumbers:Array[1..7]Of Byte;{0..255}
    TheUser:Byte;
    Index:Byte;
    Result:Byte;
Begin
     Result:=0;
     Clrscr;{Clear the Screen}
     Randomize;{shuffling..}
     For Index:=1 To 7 Do   {array filling with random numbers}
        Begin
           TheNumbers[Index]:=1+Random(10);{see my notes!!!!}
           {write these values to the screen}
           WriteLn(Index,'. element: ',TheNumbers[Index]);
        End;
     Delay(2000);{delaying about 2000 milliseconds}
     {Clear again the screen}
     ClrScr;
     {questioning}
     For Index:=1 To 7 Do
        Begin
           Write(Index,'. element: ');
           ReadLn(TheUser);
           If (TheUser = TheNumbers[Index]) Then
              Begin
                 WriteLn('Good');
                 Inc(Result); {this will be the correct answer }
              End
           Else
              WriteLn('Error');
        End;
     WriteLn;
     {write the results}
     Write('Total Points: ',Result,' of 7.');
     ReadKey;
End.

{
-= Note By FlamingClaw =-

 -=Random (function)=-
 Returns a random number.
 Declaration:
 function Random [ ( Range: Word) ]: < Same type as parameter >;
 Target:
 Windows, Real, Protected
 Remarks:
 To initialize the Random number generator,
 call Randomize, or assign a value to RandSeed.
 Return Value:
 A Word random number within the range 0 <= X < Range.
 *** *** *** *** *** *** *** *** *** *** *** *** ***
-=Inc (procedure)=-
 Increments a variable.
 Declaration:
 procedure Inc(var X [ ; N: Longint ] );
 Target:
 Windows, Real, Protected
 Remarks:
 X is an ordinal-type variable or a variable of
 type PChar if the extended syntax is enabled
 and N is an integer-type expression. X is
 incremented by 1, or by N if N is specified;
 that is, Inc(X) corresponds to X := X + 1, and
 Inc(X, N) corresponds to [X := X + N.]
 Inc generates optimized code and is especially
 useful in tight loops.
 *** *** *** *** *** *** *** *** *** *** *** *** ***
 -=Delay (procedure)(Crt unit)=-
 Delays a specified number of milliseconds.
 Declaration:
 procedure  Delay(MS: Word);
 Target:
 Real, Protected
 Remarks:
 Ms specifies the number of milliseconds to
 wait.
 Delay is an approximation, so the delay period
 will not last exactly Ms milliseconds.

-=Created By FlamingClaw=-
-=2009.03.20=-
}

Question 2
:)

Program Program01;

Uses Crt;

Var
     Chars:Array[97..122]Of Char;  {a..z}
     h:String[26];{string max length 26 char}
     x,y,i:Byte;  {index}
     S,E:Char; {user's answer}

Begin
     ClrScr;
     H:='';  {empty string}
     {fill the array with characters}
     For i:=97 To 122 Do 
        Begin
           Chars[i]:=Chr(i);{see my notes}
           Write(Chars[i],' ');
        End;
     WriteLn;
     {ask the user to write the start letter}
     Write('Start: ');
     ReadLn(S); {catch the answer}
     x:=Ord(S); {see my notes}
     Write('End: ');
     Read(E);
     y:=Ord(E);
     {write the asked results}
     For i:=x To y Do
        Begin
          H:=H+Chars[i];{this is the trick...}
          WriteLn(H);{write the result}
        End;

     ReadLn;
     Readln;
End.

{
-= Note By FlamingClaw =-
*** *** *** *** *** *** *** *** *** *** *** ***
-=Ord (function)=-
Returns the ordinal value of an ordinal-type
expression.
Declaration:
function Ord(X): Longint;
Target:
Windows, Real, Protected
Remarks:
X is an ordinal-type expression. The result is
of type Longint and its value is the
ordinality of X.
*** *** *** *** *** *** *** *** *** *** *** ***
-=Chr (function)=-
Returns a character with a specified ordinal
number.
Declaration:
function Chr(X: Byte): Char;
Target:
Windows, Real, Protected
Remarks:
Chr returns the character with the ordinal
value (ASCII value) of the byte-type
expression, X.
-=Created By FlamingClaw=-
-=2009.03.22=-
}

I think that your problem's solved,mark as solved!!!!!!!!!!
If it is not the good solution then notify me or the others
Or don't ask if you don't know the 'Mark as Solved' button!
And next time one thread one question,thanx.:P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.