Loop problem 
Author Message
 Loop problem

--



Wed, 18 Jun 1902 08:00:00 GMT  
 Loop problem

On Sun, 14 Jun 1998 10:00:15 -0400, James Morrish

Quote:

>--

A concise yet thorough outline of your problem.

----------------------------
"Eagles may soar, but weasels aren't sucked into jet engines."

http://www.flatworld.u-net.com/home.htm - newly redesigned



Wed, 18 Jun 1902 08:00:00 GMT  
 Loop problem

The following piece is a loop problem that I am having. The
program accepts a number and converts it. When another conversion
is required the program issues a error. Can anyone help me.
================================================================
{main program}
  var
   octal:string;
   count:longint;
   hex1:array[1..4]of integer;
   hex2:hexadecimal;
   remain1,remain2,remain3,wordlen,num:integer;
   total_decimal: longint;
   reply : char;
   begin {of main program}
         reply := 'y';
         while reply = 'y' do
          begin
         Enter_Octal (Octal);
         Octal_to_Decimal (Octal,total_decimal);
         Decimal_to_Hexadecimal (hex2,total_decimal);
         Display_Hexadecimal (hex2,Octal);
         end;
end.

--



Wed, 18 Jun 1902 08:00:00 GMT  
 Loop problem



Quote:
> On Sun, 14 Jun 1998 10:00:15 -0400, James Morrish

> >--

> A concise yet thorough outline of your problem.

> ----------------------------
> "Eagles may soar, but weasels aren't sucked into jet engines."

> http://www.flatworld.u-net.com/home.htm - newly redesigned

And the sardines will always come to the trawler


Wed, 18 Jun 1902 08:00:00 GMT  
 Loop problem



Quote:
> The following piece is a loop problem that I am having. The
> program accepts a number and converts it. When another conversion
> is required the program issues a error. Can anyone help me.
> ================================================================
>>    begin {of main program}
>          reply := 'y';
>          while reply = 'y' do
>           begin
>          Enter_Octal (Octal);
>          Octal_to_Decimal (Octal,total_decimal);
>          Decimal_to_Hexadecimal (hex2,total_decimal);
>          Display_Hexadecimal (hex2,Octal);
>          end;
> end.

> --
>   where is the value reply generated from at the end of your program ????

      as it reads your program should loop forever as there is no condition
set at the end to read the reply unless of course you have forgot to
include this or is it in another procedure????. The easiest solution to
this is to read in the reply before you end the loop i.e. write('Do it
again (y/n) : ');
                                         readln(reply);
                                         end loop


Wed, 18 Jun 1902 08:00:00 GMT  
 Loop problem

Quote:
> The following piece is a loop problem that I am having. The
> program accepts a number and converts it. When another conversion
> is required the program issues a error. Can anyone help me.

   Well, what are we supposed to do with _this_?  For all I see, it's
just some pseudo-code showing the logic flow of a program (did you write
it yourself, or is it only the skeleton your instructor gave you?), and
you (once again) provide us with no actual information: what error? where
does it occur? what data values did you use?
   I can see some things I personally don't like (e.g. the procedure
parameters for each subprogram don't seem to be in a consistent "input,
output" order, but that's possibly only a style matter.  The real problem
is that no one can see what's actually going on in the program (the real
functional code is missing), and you haven't told us _anything_ about the
"error"...
   You'll never get any help (here or elsewhere) if you don't "come
clean" with your requirements, code, and full problem description.  You
know, there's that old saying about "God helps those who help
themselves." - it also applies here...
Quote:
> ================================================================
> {main program}
>   var
>    octal:string;
>    count:longint;
>    hex1:array[1..4]of integer;
>    hex2:hexadecimal;
>    remain1,remain2,remain3,wordlen,num:integer;
>    total_decimal: longint;
>    reply : char;
>    begin {of main program}
>          reply := 'y';
>          while reply = 'y' do
>           begin
>          Enter_Octal (Octal);
>          Octal_to_Decimal (Octal,total_decimal);
>          Decimal_to_Hexadecimal (hex2,total_decimal);
>          Display_Hexadecimal (hex2,Octal);
>          end;
> end.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. another small loop problem

2. Q- Looping Problems

3. For-Do Loop Problem

4. display/loop problems

5. Loop Problems

6. Problem with a for loop

7. Problem with a for loop

8. exit out of loop question

9. Speeding up interation within while not Eof loop

10. Loop counter decrement by 2

11. loop a table

12. filter loop???

 

 
Powered by phpBB® Forum Software