Help 
Author Message
 Help

How can I write a for loop that prints the odd number from 11 through 23



Sat, 05 Dec 1998 03:00:00 GMT  
 Help

Quote:
> How can I write a for loop that prints the odd number from 11 through 23

   There are several ways (to do this obvious homework assignment).  One
is to use the Odd function, and the other doesn't print the loop control
variable.  There, I've given you a couple of useful hints; go work it out
for yourself...and get your own class credit.


Sat, 05 Dec 1998 03:00:00 GMT  
 Help

Quote:

>How can I write a for loop that prints the odd number from 11 through 23

How's about:

for i := 11 to 23 do
  if Odd( i ) then
    Write( i ) ;

HTH

-* Stephen *-
Stephen Posey
University of New Orleans

WWW    : http://www.uno.edu/~slp



Sun, 06 Dec 1998 03:00:00 GMT  
 Help

Quote:
> >How can I write a for loop that prints the odd number from 11 through 23
> How's about:

> for i := 11 to 23 do
>   if Odd( i ) then
>     Write( i ) ;
> Stephen Posey
> University of New Orleans

> WWW    : http://www.uno.edu/~slp

   I see that you attend college, but do you feel it's really necessary
to _give_ someone's homework assignment to them - without any sort of
explanation which might actually _help_ him understand the problem?  Or,
is that how you've survived Higher Education to this point, begging for
help to get your work done for you?  <Sheeesh...>  8<{{


Sun, 06 Dec 1998 03:00:00 GMT  
 Help

Quote:

>> >How can I write a for loop that prints the odd number from 11 through 23
>> How's about:

>> for i := 11 to 23 do
>>   if Odd( i ) then
>>     Write( i ) ;
>> Stephen Posey
>> University of New Orleans

>> WWW    : http://www.uno.edu/~slp
>   I see that you attend college, but do you feel it's really necessary
>to _give_ someone's homework assignment to them - without any sort of
>explanation which might actually _help_ him understand the problem?  Or,
>is that how you've survived Higher Education to this point, begging for
>help to get your work done for you?  <Sheeesh...>  8<{{

Mike,

(I'm feeling very mischievous today, so take this with a lot of salt!)
Maybe Stephen is smart enough to desire to eliminate his competition,
he is doing this by insuring that future rivals get good grades but
learn nothing.



Mon, 07 Dec 1998 03:00:00 GMT  
 Help



Quote:
> How can I write a for loop that prints the odd number from 11 through 23

for i:=11 to 23 do
 begin
  WriteLn(i);
  Inc(i);
 end;

I Think ;)

--
Daniel Silverstone



Tue, 08 Dec 1998 03:00:00 GMT  
 Help

Quote:


>Subject: Help
>Date: Tue, 18 Jun 1996 13:43:52 -0500
>How can I write a for loop that prints the odd number from 11 through 23

How about this:
...
var i : longint
...
for I := 11 to 23 do
   if odd(I) then writeln(I);

greetings from Luxembourg
zz



Tue, 08 Dec 1998 03:00:00 GMT  
 Help


Quote:


>> How can I write a for loop that prints the odd number from 11 through 23
>for i:=11 to 23 do
> begin
>  WriteLn(i);
>  Inc(i);
> end;

Answer to everyone in this thread....

I don't think I'm going to answer this one because it sounds like some
brat's homework assignment....but this implentation is wrong, and the
other one could be done better....but ah well....if the little brat
can't do something as simple as what q he asked, he's got a problem!



Tue, 08 Dec 1998 03:00:00 GMT  
 Help

Quote:




>>> How can I write a for loop that prints the odd number from 11 through 23
>>for i:=11 to 23 do
>> begin
>>  WriteLn(i);
>>  Inc(i);
>> end;
>Answer to everyone in this thread....
>I don't think I'm going to answer this one because it sounds like some
>brat's homework assignment....but this implentation is wrong, and the
>other one could be done better....but ah well....if the little brat
>can't do something as simple as what q he asked, he's got a problem!

How sad! Lets try

for i:=1 to 1 do
   WriteLn(11,13,15,17,19,21,23);

after all, I wouldn't compute pi every time I needed to use it, and I
already know what all the odd numbers between 11 and 23 are.



Tue, 08 Dec 1998 03:00:00 GMT  
 Help

Quote:

>> >How can I write a for loop that prints the odd number from 11 through 23

>> How's about:

>> for i := 11 to 23 do
>>   if Odd( i ) then
>>     Write( i ) ;
>> Stephen Posey
>> University of New Orleans

>> WWW    : http://www.uno.edu/~slp

>   I see that you attend college, but do you feel it's really necessary
>to _give_ someone's homework assignment to them - without any sort of
>explanation which might actually _help_ him understand the problem?  Or,
>is that how you've survived Higher Education to this point, begging for
>help to get your work done for you?  <Sheeesh...>  8<{{

I'll take the rap for taking the risk that this might have been
someone's homework, though I found it rather unlikely that someone's
ENTIRE homework assignment consisted of printing out a few odd numbers
(though I could be wrong).   If it's any consolation, the original
poster Emailed me directly asking how this should be "run" to which I
replied that it's not a complete program and I wasn't going to just give
him all that too.

Regards,

Stephen Posey

Work:                                                              Home:
User Services Consultant                                
^^^^^^^^^^^^^^^^^^^^^^^^

Perhaps I should have known better, hunh? ;-)

University Computing and Communications
University of New Orleans                                1128 Pauline St
New Orleans, LA 70148                              New Orleans, LA 70117
USA                                                                  USA
Phone : (504)286-6396                              Phone : (504)943-3852
FAX   : (504)286-6348

WWW   : http://www.uno.edu/~slp

-* Stephen *-
Stephen Posey
University of New Orleans

WWW    : http://www.uno.edu/~slp



Tue, 08 Dec 1998 03:00:00 GMT  
 Help



Quote:

>How sad! Lets try

>for i:=1 to 1 do
>   WriteLn(11,13,15,17,19,21,23);

>after all, I wouldn't compute pi every time I needed to use it, and I
>already know what all the odd numbers between 11 and 23 are.

That writes 11131517192123.

--

    Home Page under construction.



Tue, 08 Dec 1998 03:00:00 GMT  
 Help

Quote:

> >How sad! Lets try

> >for i:=1 to 1 do
> >   WriteLn(11,13,15,17,19,21,23);

> >after all, I wouldn't compute pi every time I needed to use it, and I
> >already know what all the odd numbers between 11 and 23 are.

> That writes 11131517192123.

   Nonetheless, I like his style in dealing with the "please do my
homework for me" issue...8<}}


Wed, 09 Dec 1998 03:00:00 GMT  
 Help

Hi there,

Quote:



> > How can I write a for loop that prints the odd number from 11 through 23
> for i:=11 to 23 do
>  begin
>   WriteLn(i);
>   Inc(i);
>  end;

> I Think ;)

> --
> Daniel Silverstone

Thats a bit messy, if you want just the odd numbers, you must test them
first before outputting them. Try:

for i := 11 to 23 do
begin
        if (i mod 2 <> 0) then
                writeln(i);
end;

Or you could just forget using a for loop and do:

i := 11;
repeat
        writeln(i);
        inc(i, 2);  {i := 1 + 2}
until (i = 23);

--

TTFN and TC, Michael Dales, official nice person.
----------------------------------------------------------------------------

Glasgow University      voice : 0141-776 5789
HTML Association        snail : 97 Iona Way, Kirkintilloch,
(WebSoc).                       Glasgow, G66 3PU.
So there.               URL   :
http://www.gla.ac.uk/Clubs/WebSoc/~9402198d/
----------------------------------------------------------------------------



Tue, 22 Dec 1998 03:00:00 GMT  
 Help

Quote:
> > > How can I write a for loop that prints the odd number from 11 through 23
> > for i:=11 to 23 do
> >  begin
> >   WriteLn(i);
> >   Inc(i);
> >  end;

> > I Think ;)

> Thats a bit messy, if you want just the odd numbers, you must test them
> first before outputting them. Try:

> for i := 11 to 23 do
> begin
>         if (i mod 2 <> 0) then
>                 writeln(i);
> end;

> Or you could just forget using a for loop and do:

> i := 11;
> repeat
>         writeln(i);
>         inc(i, 2);  {i := 1 + 2}
> until (i = 23);

   It's more than "messy" - it's a violation of the usage of the For
loop: you're not allowed to alter the value of the For loop control
variable, and changing I in the loop for which I uses I as the control
variable violates the rule and has horrible implications.
   Your solution is somewhat cumbersome, too, because Mod is not the
cleanest way - the one his instructor probably wanted him to use (it was
a class assignment, after all...).  If you're going to iterate through
the whole series and select only the odd values, Pascal has a nice
function which helps: Odd(n).


Tue, 22 Dec 1998 03:00:00 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP............

2. Lousy Palette - help, help, help, help, help...

3. HELP HELP HELP HELP!!!

4. HELP!!HELP!!HELP!!HELP!!

5. MDB without ODBC?? Help Help Help

6. help-help-help: convert paradox database to another

7. HELP HELP HELP!!!

8. help help help me!!!!

9. HELP.. HELP ...HELP

10. Help, Help, Help BCD

11. Help, Help, Help BCD

12. HELP HELP HELP!!!!

 

 
Powered by phpBB® Forum Software