Hello,

apart from the long title (I used the better one used by toolic) and the poorly formatted text I suggest you to sign in order, in the future, to be able to edit your own post. For you personal colture PERL does not exists: Perl is the language name and perl is the program that executes your programs.

The, first, basic rule in programming is to translate a spoken problem or algorithm to a program.

> I must write a PERL program that randomly generates a number between 1 and 50 in groups of 5. Sum each group and display the results so that each number is on its own line.

The missing spec is: how many times you want to do this? let's say 3 time..

Let's see:

# a PERL program that.. use strict; use warnings; # the missing spec: 3 times for (1..3){ my $sum; # in groups of 5 for (1..5){ # randomly generates a number between 1 and 50 # Sum each group $sum += int (rand(50)+1); } # display the results so that each number is on its own line print "$sum\n"; }

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: Sum group of numbers and display each number is on its own line -- plain way by Discipulus
in thread Dice roll chances by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.