CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Just a quickie

 



Evil_Edna
Deleted

Aug 16, 2000, 1:00 AM

Post #1 of 6 (623 views)
Just a quickie Can't Post

Unfortunately I can't run PERL programs on this computer, and I'm a bit slow this morning....What would the final value of $total be?

$total=0;
for ($loop=0;$loop<=5;$loop++)
{
$total += $loop;
}
print "FINAL: $total\n";

Cheers.
Love from Me.

------------------
Always...Sometimes...Maybe...Never.


Cure
User

Aug 15, 2000, 10:02 PM

Post #2 of 6 (623 views)
Re: Just a quickie [In reply to] Can't Post

The final value of $total is 15


Cure


Kanji
User / Moderator

Aug 16, 2000, 4:58 AM

Post #3 of 6 (623 views)
Re: Just a quickie [In reply to] Can't Post

I wasn't going to reply, but Evil Edna brings back such fond memories of Willo the Wisp that I couldn't help myself. :)))

Anyhoo, the answer's 0 + 1 + 2 + 3 + 4 + 5 = well, that's basic math. You can figure that one out, surely. Smile


Evil_Edna
Deleted

Aug 16, 2000, 5:12 AM

Post #4 of 6 (623 views)
Re: Just a quickie [In reply to] Can't Post

Yeah, thanks, I thought that's what it would be, but I feel like Gumby Brain Specialist - "My brain hurts!". Oh well, I can't believe I've found someone else who knows who Evil Edna is. Woohoo!



Kanji
User / Moderator

Aug 16, 2000, 6:44 AM

Post #5 of 6 (623 views)
Re: Just a quickie [In reply to] Can't Post

[ Completely OT here ... ]

It's been yonks since I last saw WtW, and that isn't likely to change since I've since transplanted myself to US soil ( I'm a Londoner Wink, but I still remember the series and Kenneth Williams quite fondly.

BTW, you check out http://www.80snostalgia.com/classictv/ sometime. It's fandabbydozy!


rGeoffrey
User / Moderator

Aug 16, 2000, 2:04 PM

Post #6 of 6 (623 views)
Re: Just a quickie [In reply to] Can't Post

And you could eliminate the whole loop with...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$last = 5;
$total = $last * ($last + 1) / 2;
print "FINAL: $total\n";
</pre><HR></BLOCKQUOTE>

But please, don't call me "surely." Smile

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives